Page 2 of 2

Re: Filter Cross site lookups - Loading failed

Posted: 15 Oct 2018
by AlexZver
Hi Roo,

I have tested your solution and I would recommend two ways to solve this issue:

1) Add a departments list instead of a choice field. Then your code is correct and should work as in the example: https://spform.com/cross-site-lookup/ca ... office-365

2) Copy a choice field on the site without using lookup. Then you can filter your employee field by using filtering by a choice field: https://spform.com/cross-site-lookup/fi ... ite-lookup

Re: Filter Cross site lookups - Loading failed

Posted: 30 Oct 2018
by Roo
(sorry for the delay - I've been away)

Reading through both options I think the second would be more suitable for my task.

In the example given it purely uses a check box as an example. How would I create the same if a (Text) choice option was to be used?

Example given:
// Checking the checkbox
var check = fd.field('Check').value() ? 1 : 0;

My Columns will show : (and more eventually)

IT
MAINTENANCE
MILL WARPING
PURCHASING
RESEARCH & DEVELOPMENT
SHOP

Re: Filter Cross site lookups - Loading failed

Posted: 30 Oct 2018
by Roo
His is the solution:

function (term, page) {
// Getting the selected department on the form
var department = fd.field('Department').value();

if (!term || term.length == 0) {
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&$orderby={LookupField}&$filter=Department eq '" + department + "' &$top=10";
}
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&$orderby={LookupField}&$filter=startswith({LookupField}, '" + encodeURIComponent(term) + "') and Department eq '" + department + "' &$top=10";

Thanks Nikita :D