Auto update of state from Pending to Inprogress when user inputs are given

gayathri34
Kilo Contributor

Auto update of state from Pending to Inprogress when user inputs are given

As a user,

I would like my request state to change from 'Pending' with reason 'awaiting caller' to 'Inprogress' when I add a comment
so that fulfiller can continue to work on request there after

I got this question and I created script as below.

gs.include('validators');

if (current.getTableName() == "sc_task") {
current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
current.state = 2;
if (gs.hasRole("itil")) {
if (email.body.assign != undefined)
current.assigned_to = email.body.assign;

if (email.body.priority != undefined && isNumeric(email.body.priority))
current.priority = email.body.priority;
}

current.update();
}

 

please help me with the solutions.

10 REPLIES 10

Hi Gayathri,

BR looks good to me.

You would need to refresh page if you are adding additional notes by using post button beside that field.

Did you impersonate with requester for user to test?

Please mark this as Correct or Helpful if it helps.

Thanks and Regards,
Abhijit

 

By marking my response as correct or helpful, you contribute to helping future readers with similar issues.
Regards,
Abhijit
ServiceNow MVP

also to debug further, you can add info message to check if BR executing and it is going inside if condition.

 

if(gs.getUserID()== current.requested_for)
{current.state = 2;

gs.addInfoMessage("Inside If condition");
}

gs.addInfoMessage("Inside Business rule");

If it is going inside business rule but not inside if condition then try below,

gs.getUserID()==current.requested_for.toString()) or gs.getUserID().toString()==current.requested_for.toString()

Let me know if you have any further queries.

Please mark this as Correct or Helpful if it helps.

Thanks and Regards,
Abhijit

By marking my response as correct or helpful, you contribute to helping future readers with similar issues.
Regards,
Abhijit
ServiceNow MVP

Hi Abhijit,

Comments added but business rule is not working.

Could you please add here screenshot of tested example. also it didn't go inside BR,right?

By marking my response as correct or helpful, you contribute to helping future readers with similar issues.
Regards,
Abhijit
ServiceNow MVP

gayathri34
Kilo Contributor

Above Br is working fine thank you for your help, but we had one more requirement addon.

below screenshot is the email trigger when state is pending and reason awaiting caller.

find_real_file.png

once user replies to the above mail then we need to change the state to working progress for this i think we need to use inbound action. Could you please help me on this.

 

Thanks,