Page 1 of 1

FIlter out inactive lookup values

Posted: 17 Dec 2018
by devinmcmahon
I have a Cross Site Lookup field looking up entries in a source table. The field also filters out lookup values based on the value of another field already Unit -> Equipment

So, customer wants to load a new list of equipment to use, and of course there are records that are already associated to the current Equipment so they need to stay in the table and be "deactivated"

Add a field to Equipment Called Active set current entries to FALSE, load new with Active = TRUE

So would this:

return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Unit/Id&$orderby={LookupField}&$expand=Unit/Id&$filter=substringof('" + encodeURIComponent(term) + "', {LookupField}) and Unit/Id eq " + unit + "&$top=10"

Simply become something like this:

return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Unit/Id&$orderby={LookupField}&$expand=Unit/Id&$filter=substringof('" + encodeURIComponent(term) + "', {LookupField}) and Unit/Id eq " + unit + " and Active eq TRUE" + "&$top=10"

Thanks

Re: FIlter out inactive lookup values

Posted: 20 Dec 2018
by AlexZver
Hi!

I'm terribly sorry for a late reply.

Please do not forget to add "Active" field name to the "select" section, something like this:

return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Unit/Id,Active&$orderby={LookupField}&$expand=Unit/Id&$filter=substringof('" + encodeURIComponent(term) + "', {LookupField}) and Unit/Id eq " + unit + " and Active eq TRUE" + "&$top=10"