Compare two People Picker fields

Forums Dynamic Forms for SharePoint Compare two People Picker fields

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

  • Author
    Posts
  • #22615

    Gerard Graham
    Participant

    Hi three

    Anyone found a way to compare two people picker fields? A scenario is an Owner and an Approver pair of fields cannot be the same user. I want to be able to alert the current user to make a change.

    Any ideas?

    Gerry

  • #22627

    Alexander Bautz
    Keymaster

    You can add this snippet to your Custom JS to have a check when saving the form:

    function dffs_PreSaveAction(){
        var pp1 = getFieldValue("PeoplePicker1");   
        var pp2 = getFieldValue("PeoplePicker2");
        if(String(pp1) === String(pp2)){
            spjs.dffs.alert({
                "title":"ERROR",
                "msg":"You cannot use the same person as Owner and Approver"
            });
            return false;
        }
    }

    Alexander

You must be logged in to reply to this topic.