Retrieving Record Numbers Instead of sys_ids in ATF

Khalid9030
Tera Contributor

Hello,

 

In ATF, we have two Record Query steps with different conditions for the same table. These two record conditions are called in the Set Field Values step(PFA). When I call these two records, I am getting the sys_ids instead of the record numbers (PFA).

Could you please advise how to retrieve the record numbers instead of the sys_ids in ATF?

1 ACCEPTED SOLUTION

@Khalid9030 

something like this

AnkurBawiskar_0-1735538021405.png

AnkurBawiskar_1-1735538032374.pngAnkurBawiskar_2-1735538044903.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-1735538084519.png

 

AnkurBawiskar_4-1735538106243.png

Output:

atf custom step.gif

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

Ankur Bawiskar
Tera Patron
Tera Patron

@Khalid9030 

record query will always give sysId and not the display field.

you will have to use custom server side script step, pass this sysId and query the table and get the number

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

@Khalid9030 

something like this

AnkurBawiskar_0-1735538021405.png

AnkurBawiskar_1-1735538032374.pngAnkurBawiskar_2-1735538044903.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-1735538084519.png

 

AnkurBawiskar_4-1735538106243.png

Output:

atf custom step.gif

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

@Ankur Bawiskar  Thanks for your response. let me try this and let you the results. 

@Khalid9030

Sure

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