The CreatorCon Call for Content is officially open! Get started here.

Why Script Include not working?

Ankita Kolhe
Tera Contributor

Hi Community,

I created a Script include which returns if the user has exactly the given role.

find_real_file.png

Calling this script include from List Control Omit Condition but it's not working while refershing the Release List.

find_real_file.png

Thanks,

Ankita

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Ankita Kolhe 

Hi,

You are using the wrong method and wrong lines; I correct them

1) it should be getRoles()

2) it should be split(',')

var au = new ArrayUtil();
var roles = gs.getSession().getRoles() + '';
var roleArray = roles.split(",");
var isRolePresent = au.contains(roleArray, role);
return isRolePresent;

In the Omit new condition script remember to initialize answer as false

line 5 should be

var answer = false;

Regards
Ankur

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

View solution in original post

13 REPLIES 13

suvro
Mega Sage

Omit new condition should be something like this

 

if(gs.hasRole('itil')){ answer = true; }

Muralidharan BS
Mega Sage

Hi Ankita,

The return statement should be false because you are asking the system to omit a new button. So try this, 

YOu can infuse your script include instead of gs.hasRole but both perform the same thing. 

var OmitNewButton = true; // omit button for all users
if(gs.hasRole('scrum_product_owner')){
OmitNewButton = false; // show button for scrum owner
}
answer = OmitNewButton;

 

Thanks

 

Chandu Telu
Tera Guru

Hi Ankita,

May i know why your calling script include ??

You can use the gs.hasRole or gs.hasRoleExactly method in UI Action 

Example

If (gs.hasRole('scrum_product_owner'){

answer = true

}

Or

 

If (gs.hasRoleExactly('scrum_product_owner'){

answer = true

}

 

Thanks
Chandu Telu
Please Mark Correct/helpful, if applicable,

 

Hi Chandu,

I'm calling Script include from List Control omit condition not from UI Action.

Also gs.hasRoleExactly won't work in Server Side.That's the reason of calling script include for the same purpose.

Thanks,

Ankita