Populating ServiceNow variable through the Workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2025 01:26 AM
I have a Workflow script, that is assigning values to different variables. Below is that script:
I have created a new variable Approval to Hire ID, and I want to assign this value also. I've written the below line but that's not working:
grReqItem.variables.u_approval_to_hire_id = current.variables.u_approval_to_hire_id;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2025 05:35 AM
are you sure when you open the form the variable has value in it?
share that RITM record where variable editor shows that variable
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2025 05:41 AM
yes, it has value in it. But it's not showing on the RITM. Below is the screenshot:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2025 05:39 AM
this is the full output:
*** Script: Approval to Hire ID from Producer:
*** Script: Found RITM: RITM0042665
*** Script: :white_heavy_check_mark: Approval to Hire ID updated successfully for RITM: RITM0042665
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2025 01:54 AM
Use setValue() to assign the variable value explicitly and ensure the record is updated
grReqItem.setValue('variables.u_approval_to_hire_id', current.variables.u_approval_to_hire_id);
grReqItem.update();
also, check if u_approval_to_hire_id exists in both catalog items.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2025 05:28 AM
Hi @PritamG,
I've tried this too, but it's not working.