Lookup filter ID

Discussions about Cross-site Lookup
Locked
Eax
Posts: 32
Joined: Wed Oct 28, 2015

20 Nov 2015

Hello guys,

I made before a cascading lookup and it's working.

Anyway, now i want to made a lookup field who can filter per ID from another list:

Exemple :

In List A, i have a Parent element,

In List B, i have many Child element with S/N and an ID as a field text from my parent's list

In List C, i want to put my lookup field from my List B and get all concernate element's from my list B

I tryed to filtering per ID but not working :(

Any idea ?

User avatar
rostislav
Moderator
Posts: 364
Joined: Mon Oct 19, 2015

20 Nov 2015

Hello,

Please, provide screenshots showing the lists with the fields in question and state what field types they are, if a field is a lookup field, state whether it is a multi-value or single-value and what list and field it points to.

Eax
Posts: 32
Joined: Wed Oct 28, 2015

20 Nov 2015

My List B :

Image

My ListC :

Image

New Item ListC :

Image

In my list in the field "Imputation", i want to get all my items from my ListB filtering by the field "Id_Affaire", so yes, multiplie value is needed

User avatar
rostislav
Moderator
Posts: 364
Joined: Mon Oct 19, 2015

20 Nov 2015

OK. So, you want to filter your lookup field results by a field. Here's how you do it:

1. Imputation (in List C) must be a plumsail lookup field. Delete and create if and as appropriate.

2. When you're creating the Imputation field (or if you have created it modify it via 'Manage plumsail lookups' button):

a. Click 'advanced settings'

b. You'll need to change the 'request items' query, here's my sample code:

Code: Select all

function (term, page) {

	  //get the value of the 'Id_Affaire' field that belongs to the current list (List C) . The field must be present on the form. If needed, you may hide it with CSS - ask if you need to.

	  var id_affaire = fd.field('Id_Affaire').value();

	  //if empty value, assign 0

	  if (!id_affaire) {

	  	id_affaire = 0;

	  }

	  //draw attention to the $filter parameter. Id_Affaire is the internal name of Id_Affaire in List B, id_affaire is the variable defined above. 

	  if (!term || term.length == 0) {

	    return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&$filter=(Id_Affaire eq " + id_affaire + ")&$orderby=Created desc&$top=10";

	  }

	  return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&$orderby={LookupField}&$filter=(Id_Affaire eq " + id_affaire + ") and startswith({LookupField}, '" + encodeURIComponent(term) + "')&$top=10";

	}
c. Click Save.

Eax
Posts: 32
Joined: Wed Oct 28, 2015

20 Nov 2015

Tank you ! :)

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 10 guests