run a business rule (2) after a business rule (1) has run
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2023 02:35 PM
Hello,
So, when technicians submit a task (or create a task from an Incident), the following Business Rule runs (Before).
(function executeRule(current, previous /*null when async*/) {
var grSecurityIncident = new GlideRecord('sn_parent_incident');
if (grSecurityIncident.get(current.parent) && grSecurityIncident.getValue('assignment_group') && grSecurityIncident.getValue('assigned_to')){
current.assignment_group = grSecurityIncident.getValue('assignment_group');
current.assigned_to = grSecurityIncident.getValue('assigned_to');
}
})(current, previous);
Now, it only runs if the parent ticket assignment group and assign to are NOT empty.
I want to create another business rule that will run after the script above which will re-assign the ticket to a different group and remove the assign to the field. before most of the tickets contain a specific Short description, I was going to say: IF ..... has the following short description... run the following:
Do you know if that is what I should do?
This is the logic:
- The technician has an incident, and he will create a task (child)
- After the technician presses submit on the task, the script above will run.
- The new task ticket will contain the Assignment Group and the Technician's name.
I want the new script to change the assignment group to a different group, and remove the assign to person.
I hope it makes sense.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2023 06:47 PM
Thanks Benjamin,
So.. I used 99 and it did not work :(. I used 101 to run after the script 1 that contains a specific short description IT WORKED!!!
but... i changed the assignment group to my new created TASK, and the assignment group returned back to Script 2 (The new one i created).
This is my criteria"
When to run : Short description = MIGUEL
Advanced:
(function executeRule(current, previous /*null when async*/) {
current.assignment_group = '056ef4e01b9d34501d84a71b234bcbe3333';
current.assigned_to = '';
})(current, previous);
I don't want it to update every time i change the assignment group, any suggestion?
When the Script 2 (the new one) was in order 99. i used setWorkflow(false), but it didn't work. Am i using it wrong?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2023 06:51 PM
by the way.. what does this mean?
!current.assigned_to
It is located on the "condition" field. in advanced
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2023 10:43 AM
@AngelP83 Regarding the condition !current.assigned_to, it can be interpreted as the assinged_to field as being empty. In a regular if statement, current.assigned_to would evaluate to true if there was a value in the assigned_to field and false if there was no value. However, an apostrophe is a not indicator. Therefore, the condition !current.assigned_to translates to the inverse of current.assigned_to.
I think there may be a misunderstanding of how business rules execute, or you may have an issue in one of your scripts. I noticed in your original post you were doing a GlideRecord query against the 'sn_parent_incident' table. Is this a custom table? I don't believe that is an actual table. Parent incidents still live on the incident table, and they are just referenced by another incident record on the 'incident' table.
Can you please paste both of your business rule scripts and their corresponding conditions in a format like shown below?
BR1:
Condition: assigned_to is not empty
Script:
function example(){
var thisIsAnExample = "na";
}
BR2:
Condition: priority is greater than 3
Script:
function example(){
var thisIsAnExample = "na";
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2023 03:45 PM
Is the documentation on this. To add to what has been posted here.