inbound action update sctask

max_danielewicz
Giga Expert

Hi All,

i do have a catalog item that as part of the workflow (ritm level) sends an email to a vendor.

I created an inbound action to read when the vendor replies to snow and i would like to update the sctask related to the ritm and to create an event. The event will trigger a notification.

The email that the vendor replies has a token related to the ritm.(Ref:MSG0996241).

When i test the inbound action removing the two lines commented, it adds the email to the comments to the ritm, but nothing else.

The inbound action's target table is "sc_req_item"

the action is as follows, but it is not updating the sctask:

gs.include('validators');

if (current.getTableName() == "sc_req_item") {
//current.work_notes = "reply from: " + email.origemail + "\n\n" + email.body_text;
//current.update();
var sysid = current.sys_id;
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item', sysid);
gr.query();
while(gr.next()) {
gr.work_notes = "reply from: " + email.origemail + "\n\n" + email.body_text;
gr.update();
}
}

gs.eventQueue('engage_response',current,null,null);

 

regards,

max

 

1 ACCEPTED SOLUTION

max_danielewicz
Giga Expert

Hi All,

 

here is what it was changed and made it work:

 

gs.include('validators');

if (current.getTableName() == "sc_req_item") {
current.work_notes = "reply from: " + email.origemail + "\n\n" + email.body_text;
current.update();
var sysid = current.number;
var sctask = email.body.task;

var gr = new GlideRecord('sc_task');
gr.addQuery('number', sctask);
gr.query();
while(gr.next()) {
gr.work_notes = "reply from: " + email.origemail + "\n\n" + email.body_text;
var assignedto = gr.assigned_to;
gr.update();
}
}
gs.eventQueue('engage_response',current,sctask,assignedto);

 

regards,

max

View solution in original post

6 REPLIES 6

thank you for your time and suggestions

max_danielewicz
Giga Expert

Hi All,

 

here is what it was changed and made it work:

 

gs.include('validators');

if (current.getTableName() == "sc_req_item") {
current.work_notes = "reply from: " + email.origemail + "\n\n" + email.body_text;
current.update();
var sysid = current.number;
var sctask = email.body.task;

var gr = new GlideRecord('sc_task');
gr.addQuery('number', sctask);
gr.query();
while(gr.next()) {
gr.work_notes = "reply from: " + email.origemail + "\n\n" + email.body_text;
var assignedto = gr.assigned_to;
gr.update();
}
}
gs.eventQueue('engage_response',current,sctask,assignedto);

 

regards,

max