Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

HR Document Template Scripting

Community Alums
Not applicable

Hello i am using follwoing code to set a value on PDF but its giving error

(function evaluateMappingFieldValue(taskGr /* GlideRecord for parent task */, mappingField /* Pre-computed mapping field value */) {

    var gr = new GlideRecord("incident");
    gr.addQuery('case_request',taskGr .sys_id);
    gr.query();
    while(gr.next())
    {
        return gr.number.toString();
    }  

})(taskGr, mappingField);
 
Can anyone help me with above
3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Community Alums 

out of the box there is no field case_request on incident table

are you sure you are using correct field to query?

I believe you should use parent field. I am not aware the HR document template is configured on which table and what's the relationship with Incident table

gr.addQuery('parent',taskGr .sys_id);
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

Community Alums
Not applicable

@Ankur Bawiskar  I replaced my custom field with case_request for the forum.

The issue is solved ! It was cross scope error 

@Community Alums 

glad to know that my comment helped and resolved it.

Please mark my response as correct and close the thread.

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