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

Raj92
Tera Expert

Hi, Try below

 function onChange(control, oldValue, newValue, isLoading, isTemplate) { if (isLoading || newValue === '') { return; } //Type appropriate comment here, and begin script below var cl = g_form.getReference('caller_id',test); function test(cl){ var gr = cl.vip; if(gr=='true'){ g_form.setValue('urgency',1); } } }

Mishti
Kilo Contributor

Hi Raj ,

 

Yes its working but can you please explain how the line function test (cl) works ???

mayur20
Tera Contributor

//Try this//

 

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

    //Type appropriate comment here, and begin script below
    var user = g_form.getReference('caller_id');
    //var urg  = g_form.getValue('urgency');

        if (user.vip =='true')

        {
            g_form.setValue('urgency','1');
            alert('This is VIP user urgency set to the P1 automatically.');
        }
    }

 

mayur20
Tera Contributor

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

    //Type appropriate comment here, and begin script below
    var vipalert = g_form.getReference('caller_id', vipfunction);

    function vipfunction(vipalert) 
    {
        if (vipalert.vip =='true')

        {
            g_form.setValue('urgency','1');
            alert('This is VIP user urgency set to the P1 automatically');
        }
    }

}