Lookup manager from one table to put in another

Forums General discussion Lookup manager from one table to put in another

This topic contains 1 reply, has 2 voices, and was last updated by  Alexander Bautz 3 months, 2 weeks ago.

  • Author
    Posts
  • #16028

    Jeff Lynch
    Participant

    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?

  • #16054

    Alexander Bautz
    Keymaster

    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 3 months, 2 weeks ago by  Alexander Bautz. Reason: Added missing info

You must be logged in to reply to this topic.