Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Client scripts on new ServiceNow Agent vs Classic Mobile app

Kasper2
Kilo Contributor

I am trying to remove an option from a choice list on the new mobile app, based on the role of the signed in user. Instance is upgraded to Madrid. 

The script is working on the Classic Mobile app - removing one of the options from the choice list. But it doesnt do anything when i connect to the same instance from the new ServiceNow Agent mobile app. 

The script looks like this: 

function onLoad() {
//Get logged in user roles

var user = g_user.hasRoleExactly('itil');
var admin = g_user.hasRoleExactly('admin');

if(user == false || admin == false){
g_form.removeOption('u_state','8');
}
}

Help will be much appreciated. 

Thanks.

3 REPLIES 3

kgag1
Tera Expert

Did you get an answer for this?

Martin78
Kilo Contributor

I have the same problem. In the documentation of ServiceNow I read that not all GlideRecord methods are suitable for the mobile app.
A suggested solution would be great.

Mike Patel
Tera Sage

try

function onLoad() {
	//Get logged in user roles
	var user = g_user.hasRoleExactly('itil');
	var admin = g_user.hasRoleExactly('admin');
	if(user == false && admin == false){
		g_form.removeOption('u_state','8');
	}
}