Assign a user role in an ATF test step

Peter Farr
Giga Contributor

I want to use the ATF to test some business rules and other customizations on the User form. One requires a test to create a user and assign a specific role. I have tried several different ways but I cannot figure out how to do this. Simply doing a "Set field values" on the the User form doesn't work. Can someone point me in the right direction?

1 ACCEPTED SOLUTION

Ankush Agrawal
ServiceNow Employee
ServiceNow Employee

Hi Peter

You can also use 'Record Insert' step. You can insert the data into the table 'sys_user_has_role' with following values:

1. user: sysID of the user

2. role: sysID of the role

3. active: true

--
Best regards
Ankush

P.S. Please mark helpful/correct as appropriate to help fellow Community user in identifying useful answers.

View solution in original post

5 REPLIES 5

Harsh Vardhan
Giga Patron

i believe the role which you are setting on user profile is a related list. 

if you see the ATF there is not a direct way to set the role on user profile. you have to write script in ATF, you can use the "Run Server Side Script" test step and get the user id from the previous steps and then you can set it. 

 

please have a look the doc link below. 

 

Run Server Side Script test step

 

 

Thanks. I'll give that a try today if I get a chance. 

Wow. Those are some pretty poor examples and skimpy documentation. It looks like the thing I need but it is going to take some work to figure out how to use the "steps" function properly to refer back. Who would have thought an example like "return x+3" would be a good demonstration of function?

Ankush Agrawal
ServiceNow Employee
ServiceNow Employee

Hi Peter

You can also use 'Record Insert' step. You can insert the data into the table 'sys_user_has_role' with following values:

1. user: sysID of the user

2. role: sysID of the role

3. active: true

--
Best regards
Ankush

P.S. Please mark helpful/correct as appropriate to help fellow Community user in identifying useful answers.