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

Please check the { } pair, the open and close count should match in right order.

 

Please add one closing "}" after line 16 before line 18.

 

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

am sorry , i checked them all and I cant find anything not right .

Could not save record because of a compile error: JavaScript parse error at line (19) column (2) problem = syntax error (<refname>; line 19)

 

(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

for(var i=0 ; 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();
}


})(current, event, email, logger, classifier);

 

 

Checked your code, as i mention earlier one closing "}" missing after If condition closed.

please copy the below code and past - i added that "}" .

(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

for(var i=0 ; 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();
}

}

})(current, event, email, logger, classifier);

 

In case - you see any error while saving , take the screen shot and share here.

 

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

Thank you, I will try it.

I haven't get error but :

 

it didnt process : Close completed task : did not create or update sc_task using current

 

Not sure why or how to check