Page 1 of 1

Filter Cross Site Lookup by ContentType

Posted: 24 Jul 2018
by RMIC
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!

Re: Filter Cross Site Lookup by ContentType

Posted: 24 Jul 2018
by Nikita Kurguzov
Dear RMIC,
Hmm, the error looks like one of the lookups on the form points to a non-existing list or library, or somewhere it cannot access. At least it looks similar to this. Make sure you don't have any lookups like that in the list.

You can try and delete the Cross-site Lookup column, see if it helps. You can also tell us more about its configuration, perhaps we can offer some solution.

Re: Filter Cross Site Lookup by ContentType

Posted: 27 Jul 2018
by RMIC
Hello Nikita,
the library is available, which is looked up.
The lookup column looks up the same library in which the column is stored. Is this possibly a problem?

If I remove the column from the form, the form will be displayed correctly.

Re: Filter Cross Site Lookup by ContentType

Posted: 27 Jul 2018
by Nikita Kurguzov
Dear RMIC,
The issue is actually most likely connected to the Display Field that you've selected in the Cross-site Lookup. Name column is not supported by neither Cross-site Lookup, nor default Lookup. This functionality should work as long as you don't use Name as the Display Field - it's a technical field and is best left alone. Try to copy Name into Title column, and use Title for the Lookup instead.

Re: Filter Cross Site Lookup by ContentType

Posted: 13 Sep 2018
by RMIC
Thank you. It works.

Filter Cross Site Lookup by ContentType

Posted: 29 Jan 2019
by Timothyhef
Years updated per Daves comments.

Can anyone confirm the same filter is used on 67 and 68s?

Re: Filter Cross Site Lookup by ContentType

Posted: 30 Jan 2019
by AlexZver
Hi!

Could you please clarify, what do you mean about 67 and 68s?