Getting Error Data Policy Exception: The following fields are read only: Created in approval table

saggi
Tera Contributor

Hello ,

I am getting a Error when trying to create a approval record to a existing RITM .

Data Policy Exception: The following fields are read only: Created . I can see that we have a data policy configured for sys_created_on field .
my code for creating approval record is
var gr = new GlideRecord('sysapproval_approver');
gr.initialize();
gr.state = 'requested';
gr. = newUserId // variable to extract user id
gr.sysapproval=req.getUniqueValue();
gr.insert();

 

1 REPLY 1

Abhijeet Khandr
Giga Expert

Hello Saggi,

The idea behind read-only data policies is exactly that: restricting write access based on the conditions you set. So, if there you set no conditions whatsoever, then you won't be able to write, unless you explicitly force it with a script.

Whenever you create a new record, what it does is system writes to that field as well, hence the error.

What you can do is create an equivalent ACL and give role-based access. Or, if all you need is client-side restriction, you can just go ahead and use a UI policy.

You can refer the below link as well

Link 1 Data Policy Exception: The following fields are read only: 

Link 2 Data Policy Behaving incorrectly

 

Regards,

Abhijeet