Load list data into vLookup tab.

Home Forums vLooup for SharePoint Load list data into vLookup tab.

Viewing 9 reply threads
  • Author
    Posts
    • #18553
      mk3jamie
      Participant

        I basically have an employee list and a vLookup that allows you to add training certificates to the employee list item. When I open my certificate vLookup tab, i have an employee name field that i want to populate directly from the main employee list item i’m currently editing.

        Is it possible to populate that vLookup when I open the tab and start filling out the vLookup list item? I.e populate it with the Employee name directly from the main list item i’m currently editing.

        Thanks again as always Alex.

      • #18580
        Alexander Bautz
        Keymaster

          Hi,
          You can add a button in the vLookup list view to update the value. Please note that you must load the vLookup data before you run this code (by showing the vLookup child table) because the snippet uses the dataobject to know which items to update.

          Add this code to the Custom JS:

          function callMeFromButton(){    
          	jQuery.each(spjs.vLookup.dataObj.vLookupTasks[spjs.dffs.data.thisItemID].items,function(id,vLookupListItem){
                  spjs.utility.updateItem({
                      "listName":"THE_LIST_GUID_OF_CHILD_LIST",
                      "id":id,
                      "data":{"Title":"Updated title!"}
                  });
              });
          }

          Change “vLookupTasks” with the name of your vLookup field, and “THE_LIST_GUID_OF_CHILD_LIST” with the GUID or display name of your child list and finally the “data” object with the key-value-pairs to set the field values like my example that updates the Title field.

          Let me know how this works out.

          Alexander

        • #18592
          mk3jamie
          Participant

            Here’s what I have so far Alex.

            function callMeFromButton(){
            jQuery.each(spjs.vLookup.dataObj.vLookupTraining[spjs.dffs.data.thisItemID].items,function(id,vLookupListItem){
            spjs.utility.updateItem({
            “listName”:”Training and Accreditation”,
            “id”:id,
            “data”:{“Employee_x0020_Name”:”Full_x0020_Name_x0020_Text”}
            });
            });
            }

            So the vLookup is contained on the Employee List, i’ve reference the correct vLookup at the top to the Training and Accreditation list. Then inside the “data” element I’ve put in the field within the Training and Accreditation list I want to populate with the corresponding value from the employee list. I’ve used their internal names.

            I’m guessing I need to add code in to link the function to a button so to trigger it on the list?

            Thanks again for your help Alex.

          • #18595
            mk3jamie
            Participant

              Forgot to mention as well, the vLookup loads an InfoPath form, if that makes any difference.

            • #18597
              Alexander Bautz
              Keymaster

                You need to call the function either automatically every time you show the vLookup table (but this might be unnecessary) or by a button like this:

                Add a HTML section to a tab, you can look at the help text to show how to create a button – basically something like this:

                <input type="button" value="Update vLookup children" onclick="callMeFromButton();return false;">

                I don’t think it matters that this is a infopath form as long as the source is a SharePoint list.

                Alexander

              • #18599
                mk3jamie
                Participant

                  Have it working as you described Alex. Added the button into the vLookup that will assign the value from my employee name directly to the employee name field on the vLookup.

                  My issue now is that Employee Name is the field I used to connect the vLookup to the Employee list. So because I’m wanting to set that automatically, the vLookups will not display as I’ve not set an employee name. Because they don’t display, I cannot use the button to assign the Employee name to them.

                  Is there a way I can connect the Employee list and the vLookup together without using the employee name? Or would i just have to use another field that would need to be filled in on the vLookup list so to connect it to the main employee list?

                  Hopefully that makes sense!

                  Thanks again Alex.

                • #18669
                  Alexander Bautz
                  Keymaster

                    Sorry for the delay. I’m not sure I understand exactly, but you can use the “_vLookupID” and “_vLookupParentID” as described in this guide: https://spjsblog.com/vlookup-for-sharepoint/vlookup-setup-example-for-sp-2010-and-2013/

                    Alexander

                  • #19155
                    mk3jamie
                    Participant

                      Hi Alex,

                      Sorry to resurrect this old issue but it’s still giving me a hard time! I’ll try to explain it a bit better now so i know why it doesn’t seem to work properly.
                      ——————————————————————————-

                      So a normal vLookup allows you to prefill values in the child, which works absolutely fine on a normal form but does not work when the form is an InfoPath custom form.

                      Prefill Child

                      So when i add my new training item via the vLookup, the parent ID will be set in the child list. However when I change the child list to display my custom infopath form, it wont allow me to pass any data to it from the vLookup.

                      I’ve tried it with multiple data-types and still nothing.
                      ——————————————————————————-

                      Is there anyway to get the vLookup to work with InfoPath and set the child value? or is there even a way to pass the URL from the parent list into the vLookup and then access that data in InfoPath?

                      As always, thanks for your time Alex.

                    • #19169
                      Alexander Bautz
                      Keymaster

                        Hi,
                        Unfortunately DFFS and vLookup only works with the default forms and there is nothing I can do to make it work in InfoPath. Are there any special reasons for keeping the InfoPath form and not going for a DFFS form?

                        Alexander

                      • #19193
                        mk3jamie
                        Participant

                          It’s what my boss insists on using, the logic behind it being you can create forms that are much more “document” like.

                          I had suggested we could build them in DFFS and customise them using the custom CSS and field CSS but there are about 50+ forms we need to build!

                          As always Alex, thanks for your time!

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