- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2020 04:29 AM
Hi, I've a custom table and with nearly 20 fields. There is a "state" field with values 1 to 5. when ever any field changes on the form except "State" field and "description(type: string field)"field the state should set the value to 1.
This can be accomplished by business rule "update" action and adding all the fields in condition in "when to run".
But is there any other way to accomplish this, because in future if some one add new field and if they have not updated the field in the business rule the functionality will not work.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2020 04:49 AM
Hi,
you can easily handle this using this approach
1) create a system property which would hold the field names such as state,description -> these are the fields for which BR should not run
2) in the script section you can determine which fields got changed; store this into an array
3) then check if the changed fields contains any of the system property value
a) if yes then your logic
b) if not then do nothing
Refer below link on how to get the changed fields in BR
Checking for Modified or Changed Fields in Script
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2020 04:35 AM
Its better to create a state handler script include and add the logic there .You can check the OOTB state handlers for incident and change.
Go through this state model document
https://docs.servicenow.com/bundle/paris-platform-administration/page/administer/state-model/concept/state-model.html
https://docs.servicenow.com/bundle/london-it-service-management/page/product/change-management/task/t_UpdateStateHandlerScriptInclude.html
Regards
Pranav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2020 04:49 AM
Hi,
you can easily handle this using this approach
1) create a system property which would hold the field names such as state,description -> these are the fields for which BR should not run
2) in the script section you can determine which fields got changed; store this into an array
3) then check if the changed fields contains any of the system property value
a) if yes then your logic
b) if not then do nothing
Refer below link on how to get the changed fields in BR
Checking for Modified or Changed Fields in Script
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2020 04:50 AM
Hi,
You can use state model functionality in servicenow to above functionality
Thanks,
Manjusha Bangale

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2020 04:58 AM
Use below function to get changed fields on server side, add this in the business rule,
this will work for scoped apps as well:
var changed _fields = getChangedFieldNames(current); function getChangedFieldNames(gr) { var result = []; var elements = gr.getElements(); var size = elements.length; for (var i = 0; i < size; i++) { var ge = elements[i]; if (ge.changes()) { result.push(ge.getName()); } } return result; }