What am I do wrong with the Related Items filter
Posted: 16 Aug 2017
I can't figure out what I am doing wrong with the Related Items filter but it isn't working the way I expect it to.
My data is arranged as follows:
List: Sections
View: All Items
Filter by form field
Form field: ID
List Field: Cemetery
When I setup like this it finds nothing.
If I set the Related Item control attributes like this it works:
List: Sections
View: All Items
Filter by form field
Form field: Cemetery
List Field: Cemetery
However, this is matching on the string not on the ID.
I thought it was a problem with how I setup the Cross-site Lookup, but I am using the default, here it is:
List: Cemeteries
Filed: Cemetery
Request items:
Item format:
Should I make the Field = ID and then use the Cemetery field in code like this:
List: Cemeteries
Filed: ID
Request items:
Item format:
My data is arranged as follows:
- Cemetery
- Section
- Lot
- Space
- Lot
- Section
List: Sections
View: All Items
Filter by form field
Form field: ID
List Field: Cemetery
When I setup like this it finds nothing.
If I set the Related Item control attributes like this it works:
List: Sections
View: All Items
Filter by form field
Form field: Cemetery
List Field: Cemetery
However, this is matching on the string not on the ID.
I thought it was a problem with how I setup the Cross-site Lookup, but I am using the default, here it is:
List: Cemeteries
Filed: Cemetery
Request items:
Code: Select all
function (term, page) {
if (!term || term.length == 0) {
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=ID,{LookupField}&$orderby={LookupField} desc&$top=10";
}
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=ID,{LookupField}&$orderby={LookupField}&$filter=startswith({LookupField}, '" + encodeURIComponent(term) + "')&$top=10";
}
Code: Select all
function(item) {
return '<span class="csl-option">' + item["{LookupField}"] + '</span>'
}
List: Cemeteries
Filed: ID
Request items:
Code: Select all
function (term, page) {
if (!term || term.length == 0) {
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select={LookupField},Cemetery&$orderby=Cemetery desc&$top=10";
}
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select={LookupField},Cemetery&$orderby={LookupField}&$filter=startswith(Cemetery, '" + encodeURIComponent(term) + "')&$top=10";
}
Code: Select all
function(item) {
return '<span class="csl-option">' + item["Cemetery"] + '</span>'
}