If the caller of incident is a VIP user then Urgency should be set to High automatically and there should be an alert to the user creating an incident.

Mishu
Tera Expert

If the caller of incident is a VIP user then Urgency should be set to High automatically and there should be an alert to the user creating an incident. I wrote the below script for this but its not working . Please suggest 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

var user = g_form.getValue('caller_id');
var urg = g_form.getValue('urgency');

If (user.VIP == 'true')

{

g_form.setvalue('urg', '1');

alert('urg is set to high');

}

//Type appropriate comment here, and begin script below

}

 

 

6 REPLIES 6

Astik Thombare2
Tera Contributor

Use GlideAjax-

Script Include:

var getVIP = Class.create();
getVIP.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getCaller: function() {
var ga = new GlideRecord('incident');
ga.get('caller_id', this.getParameter('sysparm_caller'));
var callerIsVip = ga.caller_id.vip;
return callerIsVip;

},


type: 'getVIP'
});

 

On change client script on Caller field-

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
g_form.setValue('urgency',3);
return;
}
var ga = new GlideAjax('getVIP');
ga.addParam('sysparm_name', 'getCaller');
ga.addParam('sysparm_caller', g_form.getValue('caller_id'));

ga.getXML(getCallerName);

function getCallerName(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == 'true') {
alert('Caller Is Vip');
g_form.setValue('urgency', 1);
}
}

}

Charan 1997
Tera Contributor

Table : Incident
Type : On Change

Field : Caller

 

Script:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

var caller = g_form.getReference('caller_id');

if(caller.vip == 'true'){

    var urg = g_form.setValue('urgency','1');
    alert("urgency is set to 1");
}


   
}