- 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 05:37 AM
Hi @TOKALAJ ,
Please follow this thread, https://www.servicenow.com/community/hrsd-forum/populate-hr-record-producer-variables-in-hr-document...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2025 05:48 AM
Hi @Community Alums , thank you for your response, but the above thread is regarding the HTML document template but I need to pre-populate the information on the pdf template
- 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:58 AM
Thank you so much @Ankur Bawiskar , the above solution really worked