Close Task via Email

SimonRudd
Kilo Explorer

Hi All,

 

To make life easier for our Service Desk, we would like the option to close tasks via an email response (similar to approvals). The idea is that the Service Desk would receive an email saying that a task is assigned to them and they have the option to either Close Complete or Close Reject.

This is based on Requests (REQ -> RITM -> TASK) and we would want the TASK to be closed.

I have tried creating an email template (using the 'mailto: approval' template as a base) and also an inbound action based on type being 'reply' and the table being task or catalog task. I have tried the following scripts, as found on the community, as an inbound action and neither work on the task or catalog task tables (these scripts are based just on close completing, to start)

SCRIPT 1

var temp =email.subject.toString().toLowerCase();

if(temp.indexOf("close task") > 0)

current.state= 3; //closed state

current.update();

SCRIPT 2

gs.include('validators');  

if (current.getTableName() == "incident") {  

if (email.subject.toLowerCase().indexOf("close task") >= 0) {  

current.incident_state= 3;

current.incident_state.setValue(3);

current.active= false;

current.work_notes= "The caller agreed that this issue was resolved";

}  

current.update();              

}

Is there something obviously wrong and/or is there an easier way to implement this functionality.

Any help or advice would be greatly appreciated.


Simon

10 REPLIES 10

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Hi Simon,



In script 1 on the second line you would either need > -1 or >= 0 as if it finds the close task string once it will == 0.



In script 2 in the second line you're checking that the table is the incident table rather than the sc_task table and then also setting incident state fields which don't exist on sc_task.


Hi



For me the scenario is kind of same whereas I need to close the TASK# coming in email in bulk. So, will modification on same code can be done.



Can somebody help me on this ?



Thanks,


Bhavisha


Hello Bhavisha,

can you share a mail in which you are receiving tasks? can you share a screenshot of email received if possible?

Thanks,

Abhishek  

Thank you,
Abhishek Gardade

Can you please create separate thread/question if possible?

Thanks,

Abhihek

Thank you,
Abhishek Gardade