What causes cross-scope errors in record producer?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 04:04 AM - edited 01-09-2025 04:14 PM
I can't set a value for variables in the server script of Record producer.
The following script is included in the server script.
ErrorAccess to api 'put(sys_user.u_record_producer_variable)' from scope 'aaa' has been refused due to the api's cross-scope access policy.
aaa is the scope containing the record producer.
Do you know how to get rid of this error?
Thank you in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 04:08 AM
Hi,
What are you trying to do here?
If you want to set value to a variable on Record Producer, it has to be done on the client side.
Alternatively you can set the value to the variable once the record is created.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 04:23 AM
Thank you for replying.
As per the following community article, it is necessary to enter the URL of the Target record in the variable URL field, so I think it must be done on the server side.
Get the sys_id of the target record to set to the ... - ServiceNow Community
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 04:28 AM
You wont get the target record url until the target record is created, so it should be done after the record is created , producer script runs before target record is inserted so you wont have the url by then.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 04:25 PM
I wrote 'current.getUniqueValue()' in the producer script and was able to get the sys_id of the target record.
But does this mean I can't set values for variables in the producer script?