- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 02:32 AM
Hi,
I want to set the sys_id of the target record to the variable of record producer.
I've seen other community articles that say this is difficult, so I asked if it was updated with the latest information.
In case it is still difficult, I will write what I want to achieve below, so if you have any advice on other methods, I would like to hear it.
The requirement is that the URL that transitions to the same record on the platform screen is displayed in Link format on the screen of the request record of the custom table on the Employee center.
Thank you in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 03:07 AM
I don't think you can get the sysId of the target record when record producer opens up.
Why not store that in a hidden variable and set it via record producer script or after insert BR script?
Didn't get your business requirement completely. please share some screenshots.
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
01-09-2025 03:01 AM
To set the sys_id of the target record to a variable in a Record Producer, it's not as difficult as some articles may suggest, but it does require proper handling of the relationship between the Record Producer, target record, and the platform screen.
Steps to achieve your requirement:
Use a Script in the Record Producer: You can use a Script in the Record Producer to set the sys_id of the target record and then generate the URL dynamically.
Create a Variable for the URL: Add a variable in the Record Producer where you want to display the link. In the script, set this variable with the URL of the target record.
Generate the URL in the Script: You can use the GlideRecord API to fetch the target record and construct the URL.
Script:
(function() {
var targetRecord = new GlideRecord('custom_table');
if (targetRecord.get(current.target_record_sys_id)) {
var recordURL = targetRecord.getLink();
producer.target_record_url = recordURL;
}
})(current, producer);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 03:27 AM - edited 01-09-2025 03:28 AM
Thank you for replying.
I confirmed in the log that I was successfully able to obtain the URL.
However, when I completed the application, the following error was displayed on the completion screen, and no value was entered in the URL variable.
Do you know any way to solve this?
ErrorAccess to api 'put(sys_user.XXX)' from scope 'YYY' has been refused due to the api's cross-scope access policy.
XXX is the URL variable on the record producer.
YYY is the scope containing the record producer.
Thank you in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 03:07 AM
I don't think you can get the sysId of the target record when record producer opens up.
Why not store that in a hidden variable and set it via record producer script or after insert BR script?
Didn't get your business requirement completely. please share some screenshots.
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