Ankur Bawiskar
Tera Patron
Tera Patron

Many a times there is a requirement to get the record's display value or number in ATF.

But when we use Record Query step OOB it gives output as record sysId and not the display value of that record.

As a workaround we can create a custom server side script step and use the script to get the output.

This can then be used in the ATF Test we create.

Example below:

1) Create a custom script step

AnkurBawiskar_0-1735540096976.png

 

2) Define the input and output variable for this step

AnkurBawiskar_1-1735540289958.png

 

AnkurBawiskar_2-1735540303376.png

 

Step Execution Script:

(function executeStep(inputs, outputs, stepResult, timeout) {

    var recordSysId = inputs.u_sysid

    var gr = new GlideRecord("incident");
    gr.addQuery("sys_id", recordSysId);
    gr.query();
    if (gr.next()) {
        outputs.u_number = gr.getDisplayValue();
        stepResult.setOutputMessage('Found the record');
        stepResult.setSuccess();
    } else {
        stepResult.setOutputMessage('Record not found');
        stepResult.setFailed();
    }


}(inputs, outputs, stepResult, timeout));

For my testing: I used these steps and it worked and gave me the number taking sysId as input

AnkurBawiskar_3-1735540337003.png

 

 

AnkurBawiskar_4-1735540336999.png

 

Output:

AnkurBawiskar_5-1735540337563.gif

Test Result Output:

AnkurBawiskar_6-1735540482719.png

 

 

 

Version history
Last update:
‎12-29-2024 10:34 PM
Updated by:
Contributors