auto populate based on lookup column

Home Forums SPJS-Lookup auto populate based on lookup column

Viewing 8 reply threads
  • Author
    Posts
    • #35605
      Jeff Lynch
      Participant

        I have a change request form, when the manager selects the staff member we want to know if they are hourly or salary, which is a choice field in the parent list. How can I automatically populate a choice field in the request list with the value from the choice field in the parent list when a staff member is selected?

        I think a cascading lookup would work but it requires an extra selection on the choice field in the request list which would be nice if that was auto populated, then I could do what I need, is there a way to do that?

      • #35608
        Alexander Bautz
        Keymaster

          I’m not sure I understand. Are you currently using the SPJS-lookup plugin to create a dropdown for selecting the staff member? – if so, change to use the autocomplete plugin where you can set additional fields based on the selection.

          Alexander

        • #35606
          SteveE
          Participant

            Hi,

            I’m kind of confused. You have a parent list that contains the user and if they are hourly/salary. You are creating a child. Why not have them create the child based on the user in the parent and then populate the field you want in the child like this https://spjsblog.com/vlookup-for-sharepoint/vlookup-user-manual/#Prefill_values_in_child

            Cascading lookup does work also, and does not require another selection. Once you pick the first field it fills out the next one: https://spjsblog.com/dffs/dffs-plugins/spjs-cascading-dropdowns/#Set_field_value

            You have another option that might work depending on your situation. You could try the autocomplete function. I don’t think it applies but it might work: https://spjsblog.com/dffs/dffs-plugins/spjs-autocomplete/#Autocomplete_in_a_text_field

          • #35624
            Jeff Lynch
            Participant

              Let me see if I can clarify, everything seems close but we have some complications.

              Parent List – we are using FullName as the Lookup in the child list – a simple SP Lookup field. In the parent list we also have Salary vs Hourly field – choice field with Hourly and Salary as the choices.

              In the child list they first select the employee from the lookup, then what I want is to auto populate a field in the child form for salary/hourly with the value.

              My first attempt was a cascading lookup on the child salary/hourly field based on the parent, but then when I try and use that value with a rule it doesn’t work because when you debug it is actually returning the ID of the parent item, not the value of salary or hourly.

              so if I can have a value that is set when you select an employee in the child list that I can use for rules to display hide various fields thats what I need. make sense?

            • #35626
              Alexander Bautz
              Keymaster

                Add this to your child NewForm Custom JS to set an onChange function on the lookup field that gets the value from the parent list and writes it to the child list.

                jQuery("#dffs_YOUR_LOOKUP_FIELD_NAME select").on("change", function(){
                    var id = jQuery(this).val();
                    var item = spjs.utility.getItemByID({
                        "listName": "YOUR_PARENT_LIST_TITLE",
                        "id": id,
                        "viewFields":["ID", "PARENT_LIST_FIELD"]
                    });
                    if(item !== null){
                        setFieldValue("CHILD_LIST_FIELD", item.PARENT_LIST_FIELD);
                    }
                });
                

                Change uppercases names to match your setup.

                Alexander

              • #35638
                Jeff Lynch
                Participant

                  Thank you for this help!!!! side note, I did not get any of these in email follow up even though I have it checked, I looked in spam, other and focused but nothing came from the dffs. thought you might want to know that.

                • #35639
                  Alexander Bautz
                  Keymaster

                    I had an error in the email functionality (plugin to wordpress stopped working after an update) that I fixed on March 15. This means any notifications between February and that date may not have been sent.

                    Alexander

                  • #35644
                    Jeff Lynch
                    Participant

                      thank you sir!!!

                    • #35645
                      Alexander Bautz
                      Keymaster

                        Thanks for your donation!

                        Best regards,
                        Alexander

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