can we write script in data policy

Gangadhar540-
Tera Contributor

can we write script in data policy

2 ACCEPTED SOLUTIONS

Rajesh Chopade1
Mega Sage

hi @Gangadhar540- 

 

Data Policies are typically used to enforce data integrity by ensuring that data entered into a record meets certain conditions. However, Data Policies themselves do not directly support the inclusion of scripting (like JavaScript) in the same way that Business Rules or Client Scripts do.

Data Policies can be used in conjunction with UI Policies and Business Rules to implement additional logic, but if you need to run complex scripts as part of enforcing data conditions, you’ll need to use other mechanisms like UI Policies, Client Scripts, or Business Rules.

 

I hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.

thank you

Rajesh

View solution in original post

Community Alums
Not applicable

Hi @Gangadhar540- ,

Unfortunately this is not possible on Data policy.

What i can recommend here is , you can try to do using business rule on the table.

 

View solution in original post

5 REPLIES 5

Rajesh Chopade1
Mega Sage

hi @Gangadhar540- 

 

Data Policies are typically used to enforce data integrity by ensuring that data entered into a record meets certain conditions. However, Data Policies themselves do not directly support the inclusion of scripting (like JavaScript) in the same way that Business Rules or Client Scripts do.

Data Policies can be used in conjunction with UI Policies and Business Rules to implement additional logic, but if you need to run complex scripts as part of enforcing data conditions, you’ll need to use other mechanisms like UI Policies, Client Scripts, or Business Rules.

 

I hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.

thank you

Rajesh

Community Alums
Not applicable

Hi @Gangadhar540- ,

Unfortunately this is not possible on Data policy.

What i can recommend here is , you can try to do using business rule on the table.

 

yad_achyut
Giga Guru

Hello @Gangadhar540-  : The Answer is No as Data Policies in ServiceNow do not support scripting directly. They are designed to enforce field-level rules (like making a field mandatory or read-only) in a declarative manner, without requiring any custom scripts.

What You Can Do with Data Policies:

  • Define conditions to determine when a policy should apply.
  • Specify rules for fields, such as:
    • Making a field mandatory.
    • Making a field read-only.

These actions are configured through the UI and do not involve writing scripts.

PrashantLearnIT
Giga Sage

Hi @Gangadhar540- 

 

This doesn't seem possible based on my understanding of the Data Policy.

However, you could try achieving the same result using a business rule on the table.

********************************************************************************************************
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.

********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect


Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************