Script in data policy

suryan
Kilo Expert

Below is the script written in UI policy to make fields as mandatory based on condition, how to write this in data policy, since it cannot be

converted since UI script is running a script.

UI policy code:

var fields = g_form.getEditableFields();

for (var x=0; x < fields.length; x++){  

  if (fields[x] != 'sys_created_on' && fields[x] != 'sys_created_by' && fields[x] != 'sys_updated_on' && fields[x] != 'sys_updated_by')  

      g_form.setReadOnly(fields[x],true);  

}

1 ACCEPTED SOLUTION

Kalaiarasan Pus
Giga Sage

This is not possible as far as I understand on Data policy


But you can try to do the same via a business rule on the table.


View solution in original post

8 REPLIES 8

Create a tablename.* ACL.


gtalreja
ServiceNow Employee
ServiceNow Employee

Hello Suryan,



If I would want to use the scripts to make any field level security, I would prefer doing it writing ACLs. As this would serve both the purpose for you.



Regards,


Gaurav Talreja


ACL security and making fields mandatory are 2 different things?


Hello Kalai,



Yes, you are right to make the field mandatory with the scripts, Business rules what would be needed in this case, which runs on the server side and perform the validation before submit/update. But to make any field read only I would still prefer the ACL. (which of course not the case here.)



Regards,


Gaurav Talreja