Filter Cross site lookups - Loading failed

Discussions about Cross-site Lookup
User avatar
Roo
Posts: 107
Joined: Tue Oct 24, 2017

11 Oct 2018

This is going to be my last question for some time :D - I Promise

I've read through the article on Filter Cross site lookups and I think I have everything correct. However I can't see what I'm doing wrong.

I have a List in a site called personnel
in that list I have Employee Name and Department.

In a Subsite I have a list that contain cross site look ups for both these field (in the sub site the columns have the same name)

In my form designer I have these two CS Lookups and what I wanted to do is for the user to choose a Department, then the subsequent dropdown is filtered to only those employees within that department.

In the Manage Lookup field, in the Employee name option I have added the following in the Request Items:

function (term, page) {
// Getting the selected Department
var DeptId = fd.field('Department').value();
if (!DeptId) {
DeptId = 0;
}

// Filtering by the selected Department
if (!term || term.length == 0) {
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Department/Id&$orderby=Created desc&$expand=Department/Id&$filter=Department/Id eq " + DeptId + "&$top=10";
}
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Department/Id&$orderby={LookupField}&$expand=Department/Id&$filter=startswith({LookupField}, '" + term + "') and Department/Id eq " + DeptId + "&$top=10";
}



I think this is correct as I have used information in the documentation - changing the appropriate fields. However, after changing the Department field I get an Error:
atcs1.jpg
atcs1.jpg (20.6 KiB) Viewed 7165 times

some error messages:


LoadListContextData @ clienttemplates.js?rev=ANYVkLsKaQttIxUm0vIobw%3D%3DTAG0:1
/_layouts/15/plumsail/crosssitelookup/select2/select2_locale_en.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
/_layouts/15/plumsail/crosssitelookup/select2/select2_locale_en-US.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
fd_Item_New.aspx?List=b48f6a49-a244-49c7-976a-ef92a55d66c7&Source=http%3A%2F%2Fhf-sp%2Fsites%2FPersonnel%2Fabsence%2FLists%2FReport_Absence%2FAllItems.aspx&RootFolder=&Web=113eb9d5-cbb8-4b6c-8910-b2579e22f958:1 Refused to execute script from 'http://hf-sp/_layouts/15/plumsail/cross ... cale_en.js' because its MIME type ('') is not executable, and strict MIME type checking is enabled.
fd_Item_New.aspx?List=b48f6a49-a244-49c7-976a-ef92a55d66c7&Source=http%3A%2F%2Fhf-sp%2Fsites%2FPersonnel%2Fabsence%2FLists%2FReport_Absence%2FAllItems.aspx&RootFolder=&Web=113eb9d5-cbb8-4b6c-8910-b2579e22f958:1 Refused to execute script from 'http://hf-sp/_layouts/15/plumsail/cross ... e_en-US.js' because its MIME type ('') is not executable, and strict MIME type checking is enabled.
/sites/Personnel/_api/web/lists('e51429f6-57b4-413b-a896-6e224ae08ec0')/items?$select=Id,Employee_x0020_Name,Department/Id&$orderby=Created%20desc&$expand=Department/Id&$filter=Department/Id%20eq%2013$top=10&_=1539266415746:1 Failed to load resource: the server responded with a status of 400 (Bad Request)

User avatar
AlexZver
Posts: 232
Joined: Mon Aug 27, 2018

12 Oct 2018

Hi Roo,

Department is a lookup column in a personnel list, am I right? If it's so, the code seems to be correct, I need some more information to solve this issue. Could you please provide a response to the request? (see the screenshot below)
Screenshot_43.png
Screenshot_43.png (44.79 KiB) Viewed 7157 times

User avatar
AlexZver
Posts: 232
Joined: Mon Aug 27, 2018

12 Oct 2018

And a screenshot of a console would be very helpful

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

12 Oct 2018

I've got two lookup fields to the personnel list Employee name (i've put the filter code on this) and department:
atcs3.jpg
atcs3.jpg (65.25 KiB) Viewed 7155 times
atcs4.jpg
atcs4.jpg (76.4 KiB) Viewed 7155 times
As requested the console screen shot:
atcs5.jpg
atcs5.jpg (180.73 KiB) Viewed 7155 times

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

12 Oct 2018

I saw this on the network tab as a bad request:
atcs6.jpg
atcs6.jpg (230.27 KiB) Viewed 7154 times
Not sure if that helps?

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

12 Oct 2018

"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"The expression \"Department/Id eq 13$top=10\" is not valid."}}}

User avatar
AlexZver
Posts: 232
Joined: Mon Aug 27, 2018

12 Oct 2018

Is a Department a lookup field in the personnel list? Do you have a separate Department list?

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

12 Oct 2018

Yes the department field is in the personnel list

User avatar
AlexZver
Posts: 232
Joined: Mon Aug 27, 2018

12 Oct 2018

I should clarify, do you have a separate Department list and a Department field is a lookup to this list? Or a department field is just a dropdown with static values?

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

12 Oct 2018

Within the personnel list I have a department field that is a static lookup.
atc7.jpg
atc7.jpg (67.81 KiB) Viewed 7150 times

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 10 guests