Filter Cross Site Lookup by ContentType

Discussions about Cross-site Lookup
Locked
RMIC
Posts: 96
Joined: Sun May 10, 2015

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!
Attachments
error.png
error.png (22.57 KiB) Viewed 11216 times

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

24 Jul 2018

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.
Cheers

RMIC
Posts: 96
Joined: Sun May 10, 2015

27 Jul 2018

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.

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

27 Jul 2018

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.
Cheers

RMIC
Posts: 96
Joined: Sun May 10, 2015

13 Sep 2018

Thank you. It works.

Timothyhef
Posts: 4
Joined: Sun Jan 27, 2019

29 Jan 2019

Years updated per Daves comments.

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

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

30 Jan 2019

Hi!

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

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 13 guests