Populate String Variable Dynamically Based on Requested For in Custom Table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thursday
Hi All,
I have a catalog item where, when a user raises a request, I need to check if the “Requested for” user exists in a custom table.
If they do, I want to populate the requester’s name into a string variable on the catalog item.
Requirement
- On catalog item load (or when “Requested for” changes), check the custom table.
- If the Requested for user exists for the specific catalog item, populate a string variable (e.g., u_requester_name) with the requester’s display name.
- Otherwise, leave it blank (or show a message)
What I tried
- Default value of the string variable:- javascript: new global.ServiceCopilotAjaxUtils().getRequest(gs.getUserID());
Issue faced
- The requester name is not populating in the string variable.
Any suggestions or examples would be highly appreciated.
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
15 hours ago
Hope you are doing good.
Did my reply answer your question?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thursday
Hi @vikasverma1,
The Script Include returns true or false.
Use an onChange Catalog Client Script. Remove isLoading from it so it works on load as well as on change of the catalog item form.
