if requested for manager manager is not vip then auto populate in another field in catalog form

Rajveer
Tera Expert

Hello Experts,

 

If requested for manager manager is not VIP then auto populate in another field in catalog form in ServiceNow. How we can achieve that

2 REPLIES 2

AshishKM
Kilo Patron
Kilo Patron

Hi @Rajveer , 

You can write onChange client script on "requested for" field and get the manager's manager reference object and can check the VIP status.

 

-Thanks,

AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Eshwar Reddy
Kilo Sage



Hi  @Rajveer 
Write an OnChange Client Script for the Requested for field. This script should use a Glide AJAX call to retrieve data from a Script Include. Based on the response received from the Script Include, the script should determine whether to display or hide a specific field on the form.

Glide AJAX

var ga = new GlideAjax('Script include name');

ga.addParam('sysparm_name', 'getManager');

ga.addParam('sysparm_caller', g_form.getValue('requested_for'));

ga.getXMLAnswer(_handleResponse);

 

function _handleResponse(answer) {

 

if(answer)

{

g_form.setDisplay('field name');

}

 

}

Script Include

getManager: function() {

var userId = this.getParameter('sysparm_caller');

var user = new GlideRecord('sys_user');

if (user.get(userId))

{

var manager = user.getValue('manager VIP field backend name');

 

Return manager;

}

 

Thanks,

Eshwar

 

Please mark this response as correct and Helpful if it helps you can mark more that one reply as accepted solution