- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2025 02:34 AM
Hi all,
I'm trying to retrieve values as a comma-separated list from a field of type List in a Document Template Script. However, I'm encountering an "undefined" or "null" error only when generating the document in the Workspace. It works fine in the Core UI.
Here is the code snippet I'm using:
var dependents = target.u_dependents; grContacts.addQuery('sys_id', 'IN', dependents);
I've tried several alternatives, including:
var dependents = target.getValue('u_dependents'); var dependents = target.getElement('u_dependents'); var dependents = target.u_dependents.toString();
Does anyone have any suggestions on how to resolve this issue?
Thank you in advance,
Victoria
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2025 04:09 AM
did you add logs and see what came in the target.u_dependents?
try this and query and then get
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
05-06-2025 04:09 AM
did you add logs and see what came in the target.u_dependents?
try this and query and then get
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