Lookup filter ID

rss

Posted by Eax - Nov 20 ’15 at 05:00

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 ?

  • rostislav
    rostislav
    Moderator
    Member for: 8 years 4 months 17 days
    #1 by rostislav Nov 20 ’15 at 05:47

    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
    Member
    Member for: 7 years 10 months 24 days
    #2 by Eax Nov 20 ’15 at 06:31

    My List B :

    My ListC :

    New Item ListC :

    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

  • rostislav
    rostislav
    Moderator
    Member for: 8 years 4 months 17 days
    #3 by rostislav Nov 20 ’15 at 07:10

    The message was removed by a forum moderator.

  • rostislav
    rostislav
    Moderator
    Member for: 8 years 4 months 17 days
    #4 by rostislav Nov 20 ’15 at 07:12

    [#2]:

     

     

    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:

    	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
    Member
    Member for: 7 years 10 months 24 days
    #5 by Eax Nov 20 ’15 at 08:33

    Tank you ! smile

Displaying 1 to 5 of 5 messages