Populate the record producer variable value to a document template field

TOKALAJ
Tera Contributor

Hi, 

 

I had a requirement to pre-populate a name field on the generated pdf document template with the value added by the end user from the record producer, I tried the below code but it is not working, can anyone guide me on this.

 

TOKALAJ_0-1743510001786.png

 

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@TOKALAJ 

I have worked on it recently and was able to fetch variable value in script of the template.

Is that variable present in MRVS or Single Row?

If in single row then it should work

If it's in MRVS then you can get the JSON and then parse and get the value

Did you try to query the record with caseGr.sys_id and then fetch?

var gr = new GlideRecord("table");
gr.addQuery("sys_id", caseGr.sys_id);
gr.query();
if (gr.next()) {
    return gr.variables.first_name.toString();
}
return '';

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

6 REPLIES 6

Thank you so much @Ankur Bawiskar , the solution that you have provided really worked

Shivalika
Mega Sage

Hello @TOKALAJ 

 

In the HR Document Template body just insert variables in this format - 

 

${variable_name}

 

You can refer 👇 SN Documentation for the same - 

 

 

https://www.servicenow.com/docs/bundle/yokohama-employee-service-management/page/product/human-resou...

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY