- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2024 08:36 AM
Hi everyone,
I need to trigger a business rule in a parent record (e.g., Incident) when a field in a related child record (e.g., Work Note) is updated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2024 12:05 AM - edited ‎10-03-2024 12:07 AM
Hi @thullurishalini ,
I accomplished this by creating a business rule on the Work Note (Journal) table (sys_journal_field) that updates a field in the parent Incident when a work note is modified. This in turn triggers a business rule on the parent Incident.
You can follow the below steps and Code for business rule to achieve this:
- Create a Business Rule on the Work Note (Journal) table (sys_journal_field).
- In the Business Rule:
a. When: After
b. Condition: You can specify your own condition, such as when a specific field is updated.
c. Script:
(function executeRule(current, previous /*null when async*/) {
if (current.element_id == 'incident') { // Check if the work note is related to an incident
var incidentGR = new GlideRecord('incident'); // Get the parent incident record
if (incidentGR.get(current.element)) {
// Write the script what you want to perform
}
}
})(current, previous);
===================================***************=========================================
"If you found my answer helpful, please give it a like and mark it as the accepted solution. It helps others find the solution more easily and supports the community!"
Thanks & Regards,
Aditya
=====================================***********==========================================
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2024 11:39 AM
Hi @thullurishalini.
Create a After BR on table (sys_journal_field) so whenever the worknote updated the BR triggers
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2024 10:16 PM
You can use the script in the BR at the advance tab as follows
if (current.your_field_name.changes()) {
var parentRecord = new GlideRecord('incident');
if (parentRecord.get(current.parent)) {
parentRecord.state = '3';
parentRecord.update();
}
}
This may help you to trigger the BR
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2024 12:25 AM
Please refer to this link. It may helps to you
Refer: https://www.servicenow.com/community/developer-forum/need-business-rule-to-update-parent-state/m-p/1...
Please mark this response as correct or helpful if it assisted you with your question.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2024 08:55 AM
@thullurishalini You’ll need to create a business rule on the child record table that runs when the specific field is updated. This rule will trigger a script that updates the parent record, causing any business rules on the parent to run.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2024 10:27 PM
To trigger a business rule in a parent record (like an Incident) when a field in a related child record (such as a Work Note) is updated in ServiceNow, you can create an After Business Rule on the Child Table and define Conditions:( For instance, you might want it to trigger only when certain fields are updated or when specific conditions are met.)
Please go through the below link:
Solved: Need Business Rule to Update Parent State - ServiceNow Community
Thanks, and Regards
Vishaal
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2024 11:49 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2024 11:54 PM
Hi,
In the scenario described, it's almost always better to create a Flow instead of writing a custom business rule,
this will most likely skip the need for scripting.