ATF: steps( sys_id of previous step) value is getting undefined.

Sriraj V
Tera Contributor

Hi All,

In my ATF test case, I have used below steps to create a record in a custom table

Step 1 : Creating a user 

Step 2 : Creating a user

Step 3 : Record Update

Step 4 : Run Server Side Script 

 

In step 4, I need to get the sys_id of the user which got created in step 1. So i have used the below lines

(function(outputs, steps, params, stepResult, assertEqual) {

var step1sysid = '6989f601376023008020036973990ebc';

var getUserSysId = steps(step1sysid).record_id;

gs.info('User id is ' + getUserSysId);

}

 

In my logs getUserSysId value is getting undefined.

Can someone help me on the same.

 

1 ACCEPTED SOLUTION

@Sriraj V 

you should use this

user instead of record_id

(function(outputs, steps, params, stepResult, assertEqual) {
// add test script here

var step1sysid = '6989f601376023008020036973990ebc';
var getUserSysId = steps(step1sysid).user; // I changed here

})(outputs, steps, params, stepResult, assertEqual);

Output variable is user for Create a User OOB Step

AnkurBawiskar_0-1677831493493.png

If my response helped please mark it correct and close the thread so that it benefits future readers.

 

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

View solution in original post

7 REPLIES 7

Sriraj V
Tera Contributor

Hi @Ankush Agrawal / @Ankur Bawiskar ,

 

Any input on this? It will be helpful for me to proceed further.

 

Regards,

Sri

Omkar Kumbhar
Mega Sage
Mega Sage

Hello @Sriraj V ,

Please check the below link

https://www.servicenow.com/community/now-platform-forum/atf-steps-sys-id-of-previous-step-evaluates-...

If I was able to help you with your case, please click the Thumb Icon and mark as Correct.

Hi Omkar,

I have referred that link and used "first_record" as well. But still i am getting undefined value only.

Ankur Bawiskar
Tera Patron
Tera Patron

@Sriraj V 

you are not opening a form then how you are updating in Step 3?

Can you share complete steps along with screenshots?

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