UI Action Button Script

Dizy M
Tera Expert

Hi!

I'd like to ask if anyone here has an idea what went wrong withthis code?

 

This is our UI Action button script. 

The requirement is if the employee company code is "0003", it will open a pop up url and if the employee code is not "0003" it will open a different pop up url.

 

function changeView(){

   var EID = g_form.getValue('u_eid');
		var table = g_form.getTableName();
		var id = g_form.getUniqueValue();	
	
 var gr = new GlideRecord("sys_user");
        gr.addQuery("sys_id", EID);
        gr.query();
        if (gr.next()) {
            if (gr.u_companycd == '0003') {
		var url = table + ".do?sys_id=" + id + "&sysparm_view=EMPLOYEEVIEW";
		g_navigation.openPopup(url);
			}
else{
		var url2 = table + ".do?sys_id=" + id + "&sysparm_view=SUPERVISORVIEW";
		g_navigation.openPopup(url2);
}

			}}

 

 But what happened  was whenever I click the UI Action button, it doesn't show anything , it doesn't work..

 

I'd appreciate any help. Thanks!

17 REPLIES 17

Hi @Ankur Bawiskar thank you for this however it still doesnt show the alert... when i clicked the button, nothing happens..  it just stays on the form

Hi @Ankur Bawiskar . I found now why its not getting any result..  I just unclicked the Client box and just change the scripts to current. Thank you for you help!

@Dizy M 

Glad to help

If my response helped please mark it correct and close the thread so that it benefits future readers.

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