Filter Cross Site Lookup by ContentType
Posted: 24 Jul 2018
Hello,
I have a CrossSiteLookup column that looks up a library for the title.
The CrossSite Lookup column should only display documents that have a specific content type.
I used the script (viewtopic.php?f=5&t=739&p=3001):
function (term, page) {
if (! term || term.length == 0) {
return "{WebUrl} / _ api / web / lists ('{ListId}') / items? $ select = Id, {LookupField} & $ orderby = Created desc & $ top = 10 &" +
"$ filter = ContentTypeId eq '0x010300C4DB8202DDA58A4B979AC8C1D217117D'";
}
return "{WebUrl} / _ api / web / lists ('{ListId}') / items? $ select = Id, {LookupField} & $ orderby = {LookupField} &" +
"$ filter = startswith ({LookupField}, '" + encodeURIComponent (term) + "') and" +
"ContentTypeId eq '0x010300C4DB8202DDA58A4B979AC8C1D217117D' & $ top = 10";
}
I have used the correct content type ID.
Then I dragged the CrossSiteLookup column onto the form (using Forms Designer).
However, the following error appears when the form is called: See attachement
When calling the form without the CrossSiteLookup column, no error appears.
What am I doing wrong? Is the filtering of the CrossSiteLookup supported until a certain version?
I have not yet checked the SharePoint logs.
Many Thanks!
I have a CrossSiteLookup column that looks up a library for the title.
The CrossSite Lookup column should only display documents that have a specific content type.
I used the script (viewtopic.php?f=5&t=739&p=3001):
function (term, page) {
if (! term || term.length == 0) {
return "{WebUrl} / _ api / web / lists ('{ListId}') / items? $ select = Id, {LookupField} & $ orderby = Created desc & $ top = 10 &" +
"$ filter = ContentTypeId eq '0x010300C4DB8202DDA58A4B979AC8C1D217117D'";
}
return "{WebUrl} / _ api / web / lists ('{ListId}') / items? $ select = Id, {LookupField} & $ orderby = {LookupField} &" +
"$ filter = startswith ({LookupField}, '" + encodeURIComponent (term) + "') and" +
"ContentTypeId eq '0x010300C4DB8202DDA58A4B979AC8C1D217117D' & $ top = 10";
}
I have used the correct content type ID.
Then I dragged the CrossSiteLookup column onto the form (using Forms Designer).
However, the following error appears when the form is called: See attachement
When calling the form without the CrossSiteLookup column, no error appears.
What am I doing wrong? Is the filtering of the CrossSiteLookup supported until a certain version?
I have not yet checked the SharePoint logs.
Many Thanks!