We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

need to get HR case number created using Record Insert

PraveenaD
Mega Contributor

Using ATF, I have created an HR case in sn_hr_core_case table using Record Insert step . 

I need the HR case number & Created date to validate in further steps. 

I have also tried Record Query, which gives me only the sys ID of the HR case record created. I need HR case number & created date. Can anyone help me?

 

6 REPLIES 6

Tanushree Maiti
Tera Patron

Hi @PraveenaD 

 

Refer:

How do I get case number from record in ATF? 

 

Also check

https://www.servicenow.com/content/dam/servicenow-assets/public/en-us/doc-type/success/quick-answer/...

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

Ankur Bawiskar
Tera Patron

@PraveenaD 

the only option is to use Custom step

I shared solution back in 2022 for this, check and enhance

How do I get case number from record in ATF? 

55.png

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Thanks for the quick response but am getting a error as "The step result was not set correctly, all steps must be set to success or failed" 

And i have also tried to set an else loop below the if, And it still failed with empty Summary in ATF

PraveenaD_0-1782390904005.pngPraveenaD_1-1782390967078.png

 

PraveenaD_2-1782391083945.pngPraveenaD_3-1782391088339.pngPraveenaD_4-1782391114983.png

 

Can you please help

@PraveenaD 

you didn't do it properly in script

the error clearly says you should set either success or fail in your script

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

    var sysId = inputs.u_sysid;
    var tableName = inputs.u_tablename;

    var gr = new GlideRecord(tableName);
    gr.addQuery("sys_id", sysId);
    gr.query();
    if (gr.next()) {
        outputs.u_number = gr.getDisplayValue();
        stepResult.setOutputMessage("The number found.");

        // Set the official step status to success
        stepResult.setSuccess();
    } else {
        // Fallback or explicit failure logic
        stepResult.setOutputMessage("Something went wrong.");
        stepResult.setFailed();
    }

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

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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