use value from lookup list as value for cascading dropdown

Home Forums Cascading dropdowns use value from lookup list as value for cascading dropdown

Viewing 6 reply threads
  • Author
    Posts
    • #36559
      Jeff Lynch
      Participant

        I have a cascading dropdown that uses a value (case pack) to determine values in the dropdown. That value is actually stored in the item list, where the item (Product) is selected in a dropdown above. How can I get that value to use as the parent column in the form with the cascade?

        List 1 – products fields include name and casepack
        List 2 – casepack – value
        List 3 – order item – includes lookup to product, and a field with partial case pack values, I want to use the casepack from list 1 to filter the dropdown in list 3 based on matches in list 2.

      • #36563
        Alexander Bautz
        Keymaster

          Can you add some screenshots or mockup of the lists involved so I can better understand what you are doing?

          Please specify whether you are using the Classic DFFS or the Modern DFFS.

          Alexander

        • #36573
          Jeff Lynch
          Participant

            This illustrates it, under product I’m using your script to get values from lookup, in there we see the casepack is 12, but how can I get the filed CasePack to populate in this item so it will force the cascaded of less than full case? If I enter a number in the item casepack, the cascade works but I can’t get the value from the product into the orderitem.

            Case pack does not have to be in the orderitem, it’s just convenient to use then to filter the less than full case dropdown. That works off of another list that has 2 columns,
            Case Pack LessthanCasePack
            6, 12 3
            12, 18 6
            12,18 9

            based on case pack = 12 my values are 3,6,9 which is correct and it works. the issue is that the 12 comes from the Product which is a lookup.

          • #36583
            Jeff Lynch
            Participant

              Oh sorry – this is classic DFFS

            • #36584
              Alexander Bautz
              Keymaster

                Thanks for the clarification – in case anyone wonders, this is the solution used to pull extra field values from a lookup field: https://spjsblog.com/2013/10/16/display-information-from-another-list-based-on-a-lookup-column-connection-updated-version/

                Add this code to your custom js:

                jQuery("#dffs_LookupColumnFIN select").on("change", function(){
                    setTimeout(function(){
                        var value = jQuery("#LookupColumnFIN_ExtraLookupFieldFIN").text();
                        setFieldValue("SetFieldFIN", value);
                    },1000);
                });
                

                Replace LookupColumnFIN with the lookup field internal name, ExtraLookupFieldFIN with the extra field that you want to pull the value from and SetFieldFIN with the internal name of the field you want to write the value to.

                There is a 1 second delay to allow for the data to be retrieved before grabbing the value.

                Alexander

              • #36610
                Jeff Lynch
                Participant

                  I added this code to the end of my custom JS and not getting anything to populate, could it be that CasePack is a number in both lookup list and parent list?

                  jQuery(“#dffs_Product select”).on(“change”, function(){
                  setTimeout(function(){
                  var value = jQuery(“#Product_CasePack”).text();
                  setFieldValue(“CasePack”, value);
                  },1000);
                  });

                  where Product is the lookup column in the parent list and CasePack is a number field in both lists that I want copied over. also the parent list is a choice field so maybe change to a simple number field?

                • #36616
                  Alexander Bautz
                  Keymaster

                    Try adding a debugger statement to the code to have the developer tools pause so you can see what is going on:

                    jQuery("#dffs_Product select").on(“change”, function(){
                    setTimeout(function(){
                    var value = jQuery("#Product_CasePack").text();
                    debugger;
                    setFieldValue("CasePack", value);
                    },1000);
                    });
                    

                    Do you get the value you expect?

                    Read more here about using the devtools: https://developer.chrome.com/docs/devtools/overview/

                    Alexander

                Viewing 6 reply threads
                • You must be logged in to reply to this topic.