Close task sc_task by email inbound

ahatem
Mega Expert

Am trying to change the status of A task ticket for example ( TASK12345) from open to close completed using inbound email action.

it will be one number or more that one on the email body, how the system will trigger that and do the action that we looking for?

 

 

1 ACCEPTED SOLUTION

Ok, so target empty is expected because we are not expecting any new record to be created via this received email. 

Any how if you can give me access or we can review all your code and configuration. 

you can send me misra.ashish [at ] gmail dot com.

Thanks,

Ashish


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

View solution in original post

26 REPLIES 26

Hi, this inbound action for updating [ closing ] the TASK only.

please check following things.

1) check if incoming emails are coming to ServiceNow.

    how to check : check the sys_email with applied filter

2) if emails are coming , open that email and check the Email Log if       it process any inbound action or not. 

3) put some gs.log('Comments1'); line in script and check system        log in syslog table if your gs.log comments are printing in log or not.

If it still not working let me know with screen shots.

 

Thanks,

Ashish

Please mark correct answer  and helpful for others if it helps you.


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

the email went through already but thats what shows in log:

 

find_real_file.png

Please check the Inbound Action Active Status, in your last screen shot it's showing active = false.

find_real_file.png


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

its already active, am wondering if i need to change the priority, but anyway in logs shows skipped all other actions, am attaching the setting how its look like not sure if am missing somthing:

 

find_real_file.png

 

find_real_file.png

Hi, Please replace the below code and test it again.

(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {

var emailBody = email.body_text; // read the email BODY
var taskList = emailBody.split(',') // where "," is delimiter
gs.log('Entering into Inbound Action - Closed Complete Task');
for(var i=0 ; i < taskList.length ;i++){

var grTask = new GlideRecord('sc_task') // Table = sc_task
grTask.addQuery('number',taskList[i]); // get the TASK Record
grTask.addQuery('active', true) // check it task is active
grTask.query();

if(grTask.next()){
grTask.state = '3' // 3 is choice code for close completed in sys_choice table for sc_task.
grTask.update();
}

}
gs.log('Exiting from Inbound Action - Closed Complete Task');
})(current, event, email, logger, classifier);

 

I added two gs.print() statement in this script, please check the system log if 'Entry' & 'Exit' gs.log entry captured in system log.

 

Thanks,

Ashish

Please mark correct answer and helpful for others if it helps you


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution