Business Rule help - update incident state when commented

Travers M
Mega Guru

I am currently trying to make it so when a user adds a comment to their incident in self serve view that it will update the incident state.   I have an incident state that is custom (10) and it's need more information.   When the user replies to email, I have that working fine and changes it to the work in progress (2) but I can't seem to get this to work when it comes to commenting through the self serve portal as it seems users do not have write access to the state field.   If that's the case, why does it work in one area and not the other?   My business rule I have in place (but doesn't work) is a "before" and "Update":

 

Condition:     current.state == '10' && current.comments.changes() && gs.getUserID() == current.caller_id

 

Script is:  

 

current.state == 2;

current.update();

 

Anyone see something that jumps out that them as being incorrect?

1 ACCEPTED SOLUTION

So I did get a solution from HI, it wasn't a conflict at all but an issue with the syntax.   Here is the answer from HI:



I'll help you resolve this issue.   Please change line 1 of the Business Rule "State to WIP if Requester Adds Comments"


from


current.state == 2


to


current.state = 2;



'Double equal signs' test for equality and a 'single equal sign' is used to assign a value.


View solution in original post

8 REPLIES 8

Mike Allen
Mega Sage

I got this to work in SANDBOX



current.state == '10' && current.comments.changes() && current.caller_id == gs.getUserID()



Also, don't use a current.update() in a before update.   It will cause two updates.


I tried yours and I'm seeing the same behavior with what I had.   It flashes real quick to be Work in Progress but that change must not save to the record because when you go back into it, it will still have the Need More Information status.


Then I wonder if you have another business rule that sets it back to that state and they are conflicting.   That is what it sounds like to me if that is what you see.


I don't have any other business rules that pertain to incident state or state.   In looking for conflicts, I did stumble onto an onLoad client script on the incident table that's called "If user has no roles, remove options" and contains:



function onLoad() {


 


  var roles = g_user.hasRoles();


  if(!roles) {


  g_form.removeOption('state', '1');


  g_form.removeOption('state', '2');


  g_form.removeOption('state', '3');


  g_form.removeOption('state', '6');


  g_form.removeOption('state', '7');


  g_form.removeOption('state', '8');


  }


}



Could that be what's causing the problem because it looks as though that's taking away option 2 or am I not understanding what that is doing?