Filtering Related Items by various field types
The Related Items control can be filtered by almost any field of the parent form. Find most popular cases below:
ID (parent) – Lookup (child)
- Navigate to the source list and add ID as an additional column of the lookup column pointing to the parent list:
List settings → Columns → Pick the lookup column → Add a column to show each of these additional fields → Pick the ID. - In Forms Designer, pick the source list in the Data Source editor and set filtering option to ‘Filter by form field’.
- Set Form Field to ID and List Field to additional column that you added on step 1.
Text (parent) – Lookup (child)
- In Forms Designer, pick the source list in the Data Source editor and set filtering option to ‘Filter by form field’.
- Set Form Field to the Text field that is used as a display field of the lookup column of the source list and List Field to the lookup field.
Lookup (parent) – Lookup (child)
- In Forms Designer, pick the source list in the Data Source editor and set filtering option to ‘Filter by form field’.
- Set Form Field to a Lookup field of the current list and List Field – to a Lookup column of the related list.
- Put an HTML-control onto the form, switch CDATA property to False and insert the following content:
<xsl:variable name="FieldValue" select="substring-before(substring-after(@Lookup,'>'),'<')"/> <xsl:comment> <xsl:value-of select="ddwrt:GenFireConnection(concat('*', '@Lookup=', ddwrt:ConnEncode(string($FieldValue))), '')" /> </xsl:comment>
Replace both occurrences of ‘Lookup’ with the internal name of the lookup field of the current list.
User (parent) – User (child)
- In Forms Designer, pick the source list in the Data Source editor and set filtering option to ‘Filter by form field’.
- Set Form Field to a User field of the current list and List Field – to a Lookup column of the related list.
- Put an HTML-control onto the form, switch CDATA property to False and insert the following content:
<xsl:variable name="FieldValue" select="substring-after(substring-before(substring-after(@User,'userdisp.aspx?ID='),'<'),'>')"/> <xsl:comment> <xsl:value-of select="ddwrt:GenFireConnection(concat('*', '@User=', ddwrt:ConnEncode(string($FieldValue))), '')" /> </xsl:comment>
Replace both occurrences of ‘User’ with the internal name of the user field of the current list.
Additional materials
Find more info in our blog:
How to filter related items by almost any field
Dynamic filtering of the Related Items with JavaScript