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.

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

Hi Ankita,

Can you confirm is script include is calling without new ??

 

In 6 th line var hasrole= new hasRoleExactlyServerSide()

 

Thanks
Chandu Telu
Please Mark āœ… Correct/helpful, if applicable,

Afrith Shariff
Tera Guru

you should specify the condition like this hasRole(). because it is a method

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

Hi Ankur,

I made the changes as per your suggestions:-

Calling this script include from Background script it's showing error as :-

Kindly help what's wrong with this?

Thanks,

Ankita

Hi Ankur,

Thanks for your response .It's working.

But this omit new condition working rarely.

find_real_file.png

But admin could see the New button on list but for admin as well New button isn;t showing.

find_real_file.png