Cascading fields in sharepoint 2013


Posted by Hamlet Cabrera Pagan - Nov 11 ’15 at 10:55

Hello , i installed like it 5 min ago your aplication "Manage PlusSail Lookups" and i will like it to know how is work!!

i want to insert a two fields type: lookup first is "MachineNr" and second one is "CustomerNr"

those two fields come form the same list name  "Machine"

My plan is when i filter "Maschine" i want to see in "CustomerNr" your CustomerNr like the same machine before i filted

i can do it something like that with your aplication and how take you


Hamlet Cabrera

  • rostislav
    Member for: 7 years 7 months 3 days
    #1 by rostislav Nov 12 ’15 at 05:42


    If I understand correctly, the functionality you want is this: when the user selects MachineNr your CustomerNr to be set to the corresponding value from the same entity as the MachineNr.

    In that case you need to:

    1. In the list with the lookup fields click 'Manage Plumsail Lookups', select MachineNr, click advanced settings and change the Request items code in the following way:

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

    We've added ",CustomerNr" to both queries here.

    2. Then open up Forms Designer and add the following code to the JavaScript editor of the required form (New and/or Edit):

     fd.field('CustomerNr').value(fd.field('MachineNr').control('data')['Id'] +';#' + fd.field('MachineNr').control('data')['CustomerNr']);

    Note that MachineNr and CustomerNr are internal names, not titles of the fields (to check the internal name go to Forms Designer, click the field and check the grid to your right).

    You may also want to have a look at this blog post here describing the setup of cascading dropdowns.

Displaying 1 to 1 of 1 messages