Home › Forums › vLooup for SharePoint › Load list data into vLookup tab.
- This topic has 9 replies, 2 voices, and was last updated 6 years, 11 months ago by mk3jamie.
-
AuthorPosts
-
-
October 26, 2017 at 08:25 #18553
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.
-
October 30, 2017 at 18:56 #18580
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
-
October 31, 2017 at 10:49 #18592
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.
-
October 31, 2017 at 18:23 #18595
Forgot to mention as well, the vLookup loads an InfoPath form, if that makes any difference.
-
October 31, 2017 at 20:55 #18597
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
-
November 1, 2017 at 14:13 #18599
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.
-
November 8, 2017 at 19:45 #18669
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
-
January 3, 2018 at 12:08 #19155
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.
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.
-
January 3, 2018 at 21:05 #19169
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
-
January 5, 2018 at 10:00 #19193
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!
-
-
AuthorPosts
- You must be logged in to reply to this topic.