Filter Cross site lookups - Loading failed

Discussions about Cross-site Lookup
User avatar
AlexZver
Posts: 232
Joined: Mon Aug 27, 2018

15 Oct 2018

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

User avatar
Roo
Posts: 107
Joined: Tue Oct 24, 2017

30 Oct 2018

(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

User avatar
Roo
Posts: 107
Joined: Tue Oct 24, 2017

30 Oct 2018

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

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests