Business Rule condition for Child incident work notes info
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2024 03:53 AM
Hello Community,
I have created BR for setting message in work notes field of child incident.
The script is working but, I am struggling with condition. Because the BR is getting executed for all new and existing child incidents.
I need the following condition:
The BR should execute only for a new created child incident. Not for existing child incidents.
Can someone help me?
Should condition be put in the condition field or directly in the script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2024 04:13 AM
Hi,
When a child incident got created you can sort the child incident by created on and use if not while if you will use while it will run for all the available child incident.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2024 07:15 AM - edited 06-22-2024 07:41 AM
Un-check 'Update' and check 'Insert' your BR with then on run on new records being created. Add:
grIncident.setWorkflow(false);
Before the 'grIncident.update();' line to prevent other BRs from running based on you update.
Or have the BR run Before and on Insert. and use current.work_notes = 'This incident created from parent Incident' + current.parent.number;. And condition 'parent', 'is not empty'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2024 10:39 AM
Hi @Baatyr Patta ,
Solution is here:
Step 1: Please uncheck to Update and check on Insert.
Step 2: Goto advance option and add the following code
current.isNewRecord() && gs.isInsert()
OR
(function executeRule(current, previous /*null when async*/) {
// Check if the incident is newly created
if (current.isNewRecord() && gs.isInsert()) {
// Your script logic here
current.work_notes = "Your message for new incidents";
// Save the record if needed
current.update();
}
})(current, previous);
If you think my answer is helpful for you or solves your problem then click on helpful or mark it as a solution
Regards
Naveed_Hussain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2024 01:40 PM - edited 06-22-2024 01:42 PM
current.update() should not be used in a Before and Insert BR.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
current.work_notes = 'This incident is created with parent: ' + current.parent.number;
})(current, previous);
is all that is needed if the Condition field on the When to run tab has 'Parent', 'is not empty'.
However, seems Batyrbek Alymku post is missing some details on how a child incident is created.