[ATF] How to retrieve Record Producer variable in another ATF Test step - Server Side Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2022 02:15 AM
How can I retrieve Record Producer Variable value 'Affected services' in another ATF test step - Run Server Side Script ?
Based on this value I have to validate Notification sent.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2022 12:08 PM
Hi,
(you didn't mentioned Is Affected services is field on backend table?)
I assume Affected services is a field on backend table.
Just created basic steps in ATF as below to retrive the values selected in Record producer while submition.
5.Run server side script:
(function(outputs, steps, params, stepResult, assertEqual) {
// add test script here
var STEP_4_SYS_ID= 'a94664da2f7199503bc559a72799b6cf'; // get the step sysid of the record submitted step =4 step
var step_4_output = steps(STEP_4_SYS_ID).record_id;
var inc=new GlideRecord('u_my_test'); //This is your Record Producer table
inc.addQuery('sys_id',step_4_output);
inc.query();
if(inc.next()){
var services=inc.getValue("cmdb_ci"); //Here you get the Affected services value
outputs.table = 'cmdb_ci'; //table for Affected services value
outputs.record_id = services; //Set outpus.record_id to services
stepResult.setOutputMessage("Successfully collected CI Service : " + outputs.record_id);
stepResult.setSuccess();
return true;
}else {
stepResult.setOutputMessage("Failed to Retrive CI record");
return false; // fail the step
}
Step6 - You can use the Run server side script output value as reference in next steps
Try let me know
Thanks
Viswa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2022 01:25 AM
Hello Viswa, thanks for reply.
Affected CI is not a field on a table, it is only variable in Record Producer, which is used in the script of Record Producer to trigger the Notification event.
In my ATF I need to validate this Notification was sent, to notifiers defined per Affected service in another custom table.
At the moment I will do it based on raw values =Cloud, Connected Office, Managed Services.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 08:06 PM
Hi Viswa,
I am trying to retrieve field variables from a submitted record in ATF. In step5 "Run server side script" how were you able to get the value of sysid?
var STEP_4_SYS_ID ='XXXXXXXXXXXXXXXXX'
Thanks,
Sai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2024 08:27 AM
Hi S_59,
Below sys_id is step 4 record sys_id;
var STEP_4_SYS_ID= 'a94664da2f7199503bc559a72799b6cf';
Below line retrives the out put of record query from step 4.
var step_4_output = steps(STEP_4_SYS_ID).record_id;