Filter documentset folder by contenttype

Discussions about Cross-site Lookup
Locked
jacob
Posts: 27
Joined: Thu Nov 30, 2017

14 Sep 2018

Hi,

I'm trying to create a lookup field to only show the documentset folders by it's contenttype and not the documents inside the folder. However, it shows me everything. Any idea what i'm doing wrong?

Code: Select all

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 '0x0120D5200097EED96070EB744C944BEB52EF7A3775'";
  }
  return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&$orderby={LookupField}&" +
    "$filter=startswith({LookupField},'" + encodeURIComponent (term) + "') and " +
    "ContentTypeId eq '0x0120D5200097EED96070EB744C944BEB52EF7A3775'&$top=10";
}

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

18 Sep 2018

Hi jacob,

Please, use the following code for this issue:

Code: Select all

function (term, page) {
  if (!term || term.length == 0) {
    return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&$filter=startswith(ContentTypeId, '0x0120')&$orderby=Created desc&$top=10";
  }
  return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&$orderby={LookupField}&$filter=startswith({LookupField}, '" + encodeURIComponent(term) + "') and startswith(ContentTypeId, '0x0120')&$top=10";
}

jacob
Posts: 27
Joined: Thu Nov 30, 2017

18 Sep 2018

Hi AlexZver,

That worked. Thank you very much!

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 10 guests