On incident form: when user with VIP = true is selected as caller in the incident, then addFielMessage to Caller field saying “This user is VIP”. Remove the message if Caller is changed then to empty or not VIP

Emmanuel26
Kilo Expert

On incident form: when user with VIP = true is selected as caller in the incident, then addFielMessage to Caller field saying “This user is VIP”. Remove the message if Caller is changed then to empty or not VIP

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Emmanuel 

update as this and check once

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

	g_form.hideFieldMsg('caller_id');
	//Type appropriate comment here, and begin script below
	g_form.getReference('caller_id', function(gr) {
		if (gr.vip.toString() == 'true') {
			g_form.showFieldMsg('caller_id', 'caller is VIP', 'info');
		}
	});
}

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

6 REPLIES 6

Murthy Ch
Giga Sage

Hello @Emmanuel

 

Have you tried anything so far?

It will be helpful and learning for you 

 

 

Thanks,

Murthy

Thanks,
Murthy

This is what i tried

 

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

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

// if (caller.vip == 'true'){
// g_form.showFieldMsg('caller','This user is VIP','info');
// }

BALAJI40
Mega Sage

Hi,

Try the below script.

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

    //Type appropriate comment here, and begin script below

    g_form.getReference('caller_id', function(gr) {
        if (gr.vip == true) {
            g_form.showFieldMsg('caller_id', 'caller is VIP', 'info');
        } else {
            g_form.hideFieldMsg();
        }
    });

}

this didn't work