ATF - Accessing reference variable sys_id in server side script

Archana Singh1
Tera Expert

Hi All,

Working on test case for creation of problem from incident. After submitting the incident form a problem record is created.

I want to access that record via the problem reference field from the incident. How to do that via server side script in atf?

Please let me know if we have any other alternative to achieve this as I need to open the problem record and then validate some field values.

Ps: Already tried via open problem record in the list view, but it doesn't seem to do anything after opening the list view.

 

Thanks

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Archana,

Here is the approach I used to test the problem created from Incident.

I was able to open successfully the problem record which got created after clicking the UI Action "Create Problem"

Script Used in Run Server Side Script: I have given Step 3 sys_id since UI Action would be clicked from that incident

You give yours

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

	var incRec = new GlideRecord('incident');
	incRec.get(steps('21af3568db1d141059badd384b961901').record_id); // sys_id of step 3

	outputs.table = 'problem';
	outputs.record_id = incRec.problem_id;   
	stepResult.setOutputMessage("Successfully Found Problem record");
	return true;
	
})(outputs, steps, stepResult, assertEqual);

find_real_file.png

find_real_file.png

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

View solution in original post

15 REPLIES 15

Can you please post a new question for this as this thread is quite older.

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

Hi Ankur,

I have posted a new question. Could you please take a look and help me please ASAP. Below is link to the post/question.

ATF - Accessing reference variable sys_id in server side script. How to retrieve a reference variabl...

Thanks,

Srinath.

Hi @Ankur bawiskar,

 

How to get record sys_id from step where you submitted incident record?? Data will not exist in real time whichever done through ATF.So, where sys_id gets populate to copy that.

 

Please need answer for this

 

Thanks,

Jayaram

 

Hi,

When you use Submit a form step it has output variable as record_id

you can use that to get the submitted record sys_id

Regards
Ankur

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

Hi Ankur;

Here you hard-coded the sys_id of step three. This value gets changes every time you running the ATF. This sys_id of the created record. How to make it dynamic. This means I need to pass the sys_id of the previous step.

 

Thanks

Balaji Prusty