Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

hrsd

Gangaiah Deepu
Tera Contributor
This onload function should work for only Managers and HRBPs but it is not working
function
onLoad() {
    // Updated as part of STRY0125550, supports in checking if the logged in user is a Manager or HRBP
    var userUtilsAjax = new GlideAjax('CCEP_UserManager_HRBPs');
    userUtilsAjax.addParam('sysparm_name', 'isManager_HRBP');
    userUtilsAjax.addParam('sysparm_userID', g_user.userID);
    userUtilsAjax.getXML(processAnswer);
}

function processAnswer(response) {
    var answer = response.responseXML.documentElement.getAttribute("answer");
    if (answer == 'true') {
        // If the user is a Manager or HRBP, make the field mandatory
        g_form.setMandatory('is_this_request_for_you', true);
    } else {
        // If the user is not a Manager or HRBP, make the field non-mandatory and hide it
        g_form.setMandatory('is_this_request_for_you', false);
        g_form.setVisible('is_this_request_for_you', false);
    }
}
1 REPLY 1

Murthy Ch
Giga Sage

Hi @Gangaiah Deepu 

I don't see any issue in your Client script. Can you also please share the script include?

 

Thanks,
Murthy