Home › Forums › General discussion › Lookup manager from one table to put in another
- This topic has 1 reply, 2 voices, and was last updated 8 years ago by
Alexander Bautz.
Viewing 1 reply thread
-
AuthorPosts
-
-
March 9, 2017 at 00:09 #16028
This may be a redundant question and advance apology if it is but:
I am trying to populate a people picker field in a list with the people picker value from another list where the Title of the other list matches the selected field of the new list.I could make a cascading dropdown that only has one value but how can i make it so that it automatically populates those related people picker values on save?
-
March 9, 2017 at 23:38 #16054
Hi,
Use something like this that you trigger on change rule on the field in the “new list”:function getPPValueFromAnotherList(){ var res, searchVal, item, ppId, ppLogin; searchVal = getFieldValue("ChoiceColumnInNewList"); res = spjs.utility.queryItems({"listName":"ListNameOfOtherList","query":"<Where><Eq><FieldRef Name='FieldToSearchInOtherList' /><Value Type='Text'>"+searchVal+"</Value></Eq></Where>","viewFields":["PeoplePickerField"]}); if(res.count > 0){ item = res.items[0]; if(item.PeoplePickerField!== null){ ppId = item.PeoplePickerField.split(";#")[0]; ppLogin = spjs.utility.userInfo(ppId).Name; setFieldValue("PeoplePickerFieldInNewList",ppLogin); } } }
- Change “ChoiceColumnInNewList” with the fieldinternalname of the field in the new list.
- Change “FieldToSearchInOtherList” with the fieldinternalname of the field to find the matching value in the other list.
- Change “PeoplePickerField” with the fieldinternalname of the field in the other list where the person is found.
- Change “PeoplePickerFieldInNewList” with the fieldinternalname of the peoplepicker field in the new list.
- Change “ListNameOfOtherList” with the display name or GUID of the other list.
Hope this helps you on the way.
Alexander
-
This reply was modified 8 years ago by
Alexander Bautz. Reason: Added missing info
-
-
AuthorPosts
Viewing 1 reply thread
- You must be logged in to reply to this topic.