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.

UI action condition help

JordyZ
Mega Sage

Hi,

 

I have a simple request that I want the "new" button on request table only visible for users who are member of a specific group AND who are from a specific company. 

My condition looks like this: gs.getUser().isMemberOf(gs.getProperty('group.test.admin')) && gs.getUser().company == 'Company Name'.

 

The first part of the condition works (the ismemberof property part), but when I add the second part (company), the new button no longer appears. I've checked that the user is in that specific company. Is there something wrong with the condition?

2 ACCEPTED SOLUTIONS

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

you can use the below to get the company

 

getCompanyRecord() Returns the company GlideRecord of the currently logged-in user. var company = gs.getUser().getCompanyRecord();

 

So your Condition on UI actions becomes something like :

gs.getUser().isMemberOf(gs.getProperty('group.test.admin')) &&  gs.getUser().getCompanyRecord().name == 'Company Name'.

 

-Anurag

View solution in original post

Mohit_Gupta
Tera Guru
Tera Guru

Hi @JordyZ ,

 

for company please use below syntaxt it will return sysid of the company 

gs.getUser().getCompanyID(); == "company_sys_id"

 

Please mark helpful if works

 

Thanks

Mohit

View solution in original post

2 REPLIES 2

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

you can use the below to get the company

 

getCompanyRecord() Returns the company GlideRecord of the currently logged-in user. var company = gs.getUser().getCompanyRecord();

 

So your Condition on UI actions becomes something like :

gs.getUser().isMemberOf(gs.getProperty('group.test.admin')) &&  gs.getUser().getCompanyRecord().name == 'Company Name'.

 

-Anurag

Mohit_Gupta
Tera Guru
Tera Guru

Hi @JordyZ ,

 

for company please use below syntaxt it will return sysid of the company 

gs.getUser().getCompanyID(); == "company_sys_id"

 

Please mark helpful if works

 

Thanks

Mohit