Client Script not working in Agent Workspace

SN Rookie
Giga Expert

Most of the client scripts which are working in normal default view of forms aren't working in Agent Workspace. 

For example - the below script is not working. How can we ensure all client scripts work fine in AW?

function onLoad()
{
	var isAdmin = g_user.hasRole('admin');
	var state = g_form.getValue('state');
	if (!isAdmin )
		{
		if(state != 3){
			g_form.removeOption('state', '3');
		}
	}
}

1 ACCEPTED SOLUTION


Hi SN Rookie,

 

'g_user.getUserID()' is not supported in Agent workspace or service portal but does in the normal SN platform as some APIs are only supported in Desktop UI(platform).
It is recommended to use 'g_user.userID' as it works in every application.

 

You can also refer to this doc for all the supported APIs :
https://docs.servicenow.com/bundle/newyork-servicenow-platform/page/build/service-portal/reference/c...

View solution in original post

7 REPLIES 7

Harsh Vardhan
Giga Patron

make sure ui type set as all. please validate this. 

Harsh Vardhan
Giga Patron

go to your client script and you will see UI Type field just set it as "ALL"

 

find_real_file.png

That didn't work Harsh..


Hi SN Rookie,

 

'g_user.getUserID()' is not supported in Agent workspace or service portal but does in the normal SN platform as some APIs are only supported in Desktop UI(platform).
It is recommended to use 'g_user.userID' as it works in every application.

 

You can also refer to this doc for all the supported APIs :
https://docs.servicenow.com/bundle/newyork-servicenow-platform/page/build/service-portal/reference/c...