- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2025 05:20 AM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2025 05:47 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2025 07:59 AM
Thank you so much @Ankur Bawiskar , the solution that you have provided really worked
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2025 05:52 AM
Hello @TOKALAJ
In the HR Document Template body just insert variables in this format -
${variable_name}
You can refer 👇 SN Documentation for the same -
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