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.

Incident application related

krishna svg
Tera Contributor

When you selected VIP Customer in caller field then system should set priority 1-critical and impact and urgency fields should be readonly.

2 REPLIES 2

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @krishna svg 

 

You can use the UI policy and set the Impact =1, urgency =1 which make priority =1  ands put condition caller.vip= True

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Sandeep Rajput
Tera Patron
Tera Patron

@krishna svg You can achieve this using a combination if client script and GlideAjax.

 

Client Script on the Caller field

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
  if (isLoading || newValue === '') {
    return; // Don't run the script if the form is loading or the caller field is empty
  }

  var ga = new GlideAjax('VIPCallerCheck'); // Name of your Script Include
  ga.addParam('sysparm_name', 'isVIP'); // Name of the function in your Script Include
  ga.addParam('sysparm_caller_sys_id', newValue); // Pass the caller's sys_id
  ga.getXML(handleVIPResponse);

  function handleVIPResponse(response) {
    var isVIP = response.responseXML.documentElement.getAttribute("answer");

    if (isVIP == 'true') {
      g_form.setValue('priority', '1'); // Set priority to Critical
      g_form.setReadOnly('impact', true);
      g_form.setReadOnly('urgency', true);
    } else if (oldValue != '' && newvalue != oldValue) { // if caller is changed and the new caller is not VIP then impact and urgency should be editable.
        g_form.setReadOnly('impact', false);
        g_form.setReadOnly('urgency', false);
    }
  }
}

 

Script Include:

var VIPCallerCheck = Class.create();
VIPCallerCheck.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
  isVIP: function() {
    var callerSysId = this.getParameter('sysparm_caller_sys_id');
    var callerGR = new GlideRecord('sys_user'); // Replace 'sys_user' if needed
    if (callerGR.get(callerSysId)) {
      return callerGR.getValue('vip') + ''; // Convert boolean to string for GlideAjax response.  Adapt 'vip' if needed.
    }
    return 'false'; // Return false if caller not found
  },
  type: 'VIPCallerCheck'
});