- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2017 08:45 AM
Hi community,
I have created a Business Rule to change the state to "Reassigned" every time the assignment group changes.
It is a Before Rule for Insert and Update.
There are two things that I want for always to happen:
- if current.operation() == 'insert' and the user belongs to the same assignment group, the state can be everything;
- if current.operation() == 'update' and the assignment group changes the state is "Reassigned"
I did a basic rule but for some reason it doesn't work.
condition: current.assignment_group.changes()
script:
if(gs.getUser().isMemberOf(current.assignment_group) && current.operation() == 'insert'){
return;
}
else{
current.state = -5;
}
For some reason if I try to pass the incident in an awaiting state, it doesn't work the first time.
Also, the condition to check if the user belongs to that group is not doing anything, because I've tried to put the state in a specific state.
Any ideas in how I can solve this?
Thank you very much
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2017 05:54 AM
It turns out, it was a very basic thing...
It had to do with the order of the Business Rule, I've changed the order to a higher number and it works perfectly.
Thank you for you help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2017 02:24 AM
Hi,
May be the field got corrupted or something, give a try with below code..
revers operation...
if( current.operation() == "update" ) {
current.state = -5;
}
else{
return;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2017 03:55 AM
Unfortunately with your code I have the same result.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2017 03:15 AM
What I've found is that if I try to change the field that I've manually changed, it will not update with the value of my script.
Example:
previous.state = 2;
manually changed value = 3
script value = -5
It ignores the script value and updates the record with the manually updated value.
So my question is, is there another "state" than "previous" and "current"? Is there something like "next"?
Because, If I change the rule to OnAfter, it works, and I can see that the state changes from the one I had in previous.state to the one that I've changed manually, and then it changes to the the state that I specify in current.state.
This means that I have a duplicate entry in the work notes showing the state changes and the reassignment count increments.
As a workaround I can manually decrement the reassignment count, just to make sure that the value remains correct, to not have something like, Reassignment count 4 was 2.
Obviously this is not an optimal solution.
Any ideas about this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2017 05:54 AM
It turns out, it was a very basic thing...
It had to do with the order of the Business Rule, I've changed the order to a higher number and it works perfectly.
Thank you for you help!