Reply To: General DFFS enhancement suggestions

Forums Requests General DFFS enhancement suggestions Reply To: General DFFS enhancement suggestions

#24027
Alexander Bautz
Keymaster

Hi,
I’ll remove the limitation that makes you have to add the _vLookupID column when using vLookup in NewForm in the next release because even though you must add the column, you don’t have to use it in the query – so this check is not necessary.

Here is a code snippet you can use to pull a user info (user list in SP) or user profile (user profile service) value from a people picker and use it to search a child list for matching records where the user info / profile property is found in a text field called AU.

Add this to your Custom JS:
Change Manager to match your people picker internal name, Department to match your user info / profile property and vLookupAU to match your vLookup column internal name. This snippet uses the user info list, but if you like to use the user profile just change the line starting with var ui = to the commented out line.

var vLookupSearchValue = "";
function refresh_vLookup(){
    vLookupSearchValue = "";
    var managerLoginName = spjs.utility.getFieldValue({"fin":"Manager","key":"loginname"});
    if(managerLoginName.length > 0){
        jQuery("#dffs_vLookupAU").show();
        // Get from User info list
        var ui = spjs.utility.userInfo(managerLoginName[0]);
        // Get from user profile service
        // var ui = spjs.utility.userProfile(managerLoginName[0]);
        var key = ui.Department;
        if(key !== null && key !== undefined){
            vLookupSearchValue = key;
        }
        spjs.vLookup._init("vLookupAU",false,true);
    }else{
        jQuery("#dffs_vLookupAU").hide();
    }
}
// Call when form loads
function dffs_ready(){
    // Timeout to ensure people picker is ready
    setTimeout(function(){
        refresh_vLookup();
    },1000);
}

Create a rule:
Create a rule that triggers on change on the Manager people picker and add refresh_vLookup to the Run these functions / trigger these rules field.

Change vLookup configuration:
Then you change your vLookup settings like the attached images.

Alexander