What causes cross-scope errors in record producer?

k_47
Tera Contributor

I can't set a value for variables in the server script of Record producer.

 

The following script is included in the server script.

 

producer.u_record_producer_variable = value;
 
As a result, the following error was returned.
 

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.

7 REPLIES 7

Anurag Tripathi
Mega Patron
Mega Patron

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.

-Anurag

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

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.

-Anurag

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?