- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2019 09:46 PM
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
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2019 10:32 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2019 09:57 PM
Hi Max,
Does your query return anything? does the code block inside your if statement execute at all?
Thanks,
Phuong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2019 10:28 PM
Hi Phuong,
if i remove comments in the following lines, it will update the ritm and create the event. but it will not update the sctask.
//current.work_notes = "reply from: " + email.origemail + "\n\n" + email.body_text;
//current.update();
regards,
max
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2019 07:36 PM
hi Phuong,
the following statements within the if work.
current.work_notes = "reply from: " + email.origemail + "\n\n" + email.body_text;
current.update();
The rest of the code, does not work.
I changed it to this, so i can get the assigned_to as a parameter but it is not working.
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('request_item', sysid);
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,assignedto,sctask);
regards,
max

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2019 09:05 PM