get sys_id before creating Record Producer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2016 06:54 PM
Hi folks,
Just wondering if it is possible to fetch the sys_id from producer object. I have read through Producer Object and it is believed this is not feasible.
Any advice?
Thanks in advance.
George
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2016 07:24 PM
Absoloutely maybe? Depends on the use case. If you wanted to populate something on the form it wouldn't work, but if you wanted to populate another table with the sys_id you'd be good.
current.sys_id in the "contains tab" in scripts.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2016 10:00 PM
HI Aric, in this case it was to populate the the record itself before the submission. it does not seem feasible to achieve so, so my colleague has to achieve the goal with another approach. Thanks for your reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2016 09:29 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2021 03:15 PM - edited 02-02-2025 03:46 PM
We can use the RP (render properties) API with the getParameterValue() method to get the sys_id of the current record producer like so. You can use this in the producer's script:
current.u_record_producer = RP.getParameterValue('sysparm_id');
This is the approach recommended by the ServiceNow documentation in the article Populate record producer data and redirect users.
You can however also use cat_item instead (yes, this works in a record producer), which is what ServiceNow use in some of their OOTB scripts, such as in their HRSD app. This has the advantage of being able to access other properties, such as the name of the record producer (via: cat_item.name):
current.u_record_producer = cat_item.sys_id;