On load pop-up message

Dawid2
Giga Guru

Hi, I want to display pop-up when form loads when contact field is guest (his userID is guest).

I wrote the script, but it fails. Any ideas why?

function onLoad() {
   //Type appropriate comment here, and begin script below
   var user = g_user.UserID();
	   
	if (user == 'guest'){
		   
		   alert("Please update Contact field to actual customer reporting the issue before proceeding");
}
				 }

 

1 ACCEPTED SOLUTION

Gaurav Bajaj
Kilo Sage

Hi,

I was wondering how you have allowed the guest user to login to the system. What you can do is to fetch the contact field value itself by

g_form.getValue('name of contact field')

 

var user = g_form.getValue('name of contact field');

if (user == 'guest'){

alert("Please update Contact field to actual customer reporting the issue before proceeding");

}

View solution in original post

6 REPLIES 6

Gaurav Bajaj
Kilo Sage

Hi,

I was wondering how you have allowed the guest user to login to the system. What you can do is to fetch the contact field value itself by

g_form.getValue('name of contact field')

 

var user = g_form.getValue('name of contact field');

if (user == 'guest'){

alert("Please update Contact field to actual customer reporting the issue before proceeding");

}

Works like a charm now, thank you.

 

One more question - how can I cancel any updates on the ticket if Contact hasn't been updated? For example - someone updates field state, but leave caller as guest, I want cancel update then.

Hi, 

You can write an after update business rule and check the value of contact field, if its still guest then you can setaction abort value as true, which means update wont work and throw an error to user.

You can also add up a custom message.

var contactField=current.u_contact_field;
if(contactField=='guest'){
	
	
	gs.addErrorMessage("Please update teh caller field value");
	current.setAbortAction(true);
}

Replace the u_contact_field with your field name.

Thanks

Gaurav

Thanks for this. Funny thing is, even though I get the error AND invalid update, the update is not being aborted and after reloading the form, whatever was changed, remains changed. Any ideas? I already lowered the order, to no avail.