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

Abhijit4
Mega Sage

Hi Gayathri,

Where did you write above script, is it BR?

If your requirement is whenever requester adds comment then change status from Pending to In Progress, you would need to write before BR with below configuration :

On Before Update BR

Condition : When state is Pending and Work notes changes

In script section, you can check if logged in user is requester then update state accordingly.


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,

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,

Raj_Esh
Kilo Sage
Kilo Sage

Hi Gayathri,

 

Not sure where you are trying the script. But I think Business rule can solve your requirement. 

 

Try business rule as follows:

 


'Before' 'update' business rule:

Condition: previous.incident_state == 4 && current.comments.changes()

Script:
current.incident_state = 2;

 

Hope it helps.

 

Thanks,

Raj

--Raj

gayathri34
Kilo Contributor

Hi,

Thanks for your help. I have created as below but it's not working please find the attached screenshots.

find_real_file.pngfind_real_file.png