ATF - Run server side script not able to get the previous step Sys ID of the record

kmsl
Kilo Contributor

I have only 3 steps.  1)Impersonate(ITIL user)  2) log  and 3) Run server side script.

There are only 1 parameters(parametrized test)  1) Group name: Change Management  (referenced)

I am using 'log' as a step to pass on group Syd ID. (step sys-id and group sys-id) are fine and working alright.

Somehow the below in my script is not working. I tried all the list options.

This line is not working:  grp_sysid = steps(last_step_sysid).record_id;

(function(outputs, steps, stepResult, assertEqual) {
    var last_step_sysid = 'b048fd8c074788105e7efc289c1ed05c';
    grp_sysid = steps(last_step_sysid).record_id;
    //grp_sysid = 'a715cd759f2002002920bde8132e7018';
    var gr = new GlideRecord('sys_user_group');
    gr.get('sys_id', grp_sysid);
    var theIDiwant = '';
    theIDiwant = gr.name;
    outputs.record_id = theIDiwant;
    gs.log('***** Group name *******: ' + outputs.record_id);
    gs.addInfoMessage(gr.name);
})(outputs, steps, stepResult, assertEqual);

I am seeing group name empty.

You may please try through a dev instance.

I appreciate any help. Thanks

9 REPLIES 9

The SN Nerd
Giga Sage
Giga Sage

Check the outputs of the Test Step you are referring to ensure you are getting the correct value.

They are different depending on the Step.

  1. Navigate to "Automated Test Framework > Step Configurations"
  2. Open the Step you are making reference to
  3. Check 'Output Variables' tab

Example for 'Order Catalogue Item'
find_real_file.png


ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

Thanks Paul.  After I wrote the above, I started finding other community posts and someone said exactly what you said.  So I did that.  I tried request_id.  Nothing.  Undefined.  I tried Request.  Nothing.  Undefined.  Then I tried to access a different step.  My first step is impersonation, so I copied that sys_id and used the variable user and it worked.  I'm beginning to wonder if Order (SP) is broken, but I'm not reading about anyone else having the same issue.  It's so odd.  

 

That is weird. You may have stumbled upon a bug.

I am building an ATF Test Recorder,  where I am currently building functionality to record the population of SC order forms and I have been able to get the Request ID out of the non-SP Order step.

I might face this issue when I try to implement for the Service Portal Order step.
I'll report back if it is broken for me too.


ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

So I'm an idiot.  I was using the normal Service Catalog steps instead of the Service Catalog (SP) steps.  Thanks for replying to my comment, though!

No worries.

Give us a helpful if it was useful or solved if it fixed your issue.

Let me know if you have any other ATF woes.


ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022