- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2017 07:53 AM
Hey all,
I have an inbound email action that I need to update work_notes in an extended task table. However, it seems I am missing something. The action runs every time, but no update to work_notes field. Any ideas? Thanks in advance.
Here is my script:
gs.include('validators');
if (current.getTableName() == "sysapproval_approver") {
var curRec = current.document_id; //associated TASK Number to find related RFE
if (gs.hasRole("u_request_for_expenditure_user")) {
if (email.subject.indexOf("Comments for Finance") >= 0) {
var worknote = "reply from: " + email.origemail + "\n\n" + email.body_text; }
var g = new GlideRecord('u_request_for_expenditure'); // find related RFE for update
g.addQuery('sys_id', curRec);
g.query();
while(g.next()) {
g.work_notes = worknote;
g.update(); }
}
}
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2017 08:49 AM
gs.include('validators');
if (current.getTableName() == "sysapproval_approver") {
var curRec = current.document_id; //associated TASK Number to find related RFE
if (gs.hasRole("u_request_for_expenditure_user")) {
if (email.subject.indexOf("Comments for Finance") >= 0) {
var worknote = "reply from: " + email.origemail + "\n\n" + email.body_text; }
var g = new GlideRecord('u_request_for_expenditure'); // find related RFE for update
g.addQuery('sys_id', curRec);
g.query();
while(g.next()) {
g.work_notes = worknote;
g.update(); }
}
}
Your variable is declared in that if statement block. Try the code listed below and see if it works.
gs.include('validators');
if (current.getTableName() == "sysapproval_approver") {
var curRec = current.document_id; //associated TASK Number to find related RFE
var worknote = ''; //Added this line
if (gs.hasRole("u_request_for_expenditure_user")) {
if (email.subject.indexOf("Comments for Finance") >= 0) {
var worknote += "reply from: " + email.origemail + "\n\n" + email.body_text; }
var g = new GlideRecord('u_request_for_expenditure'); // find related RFE for update
g.addQuery('sys_id', curRec);
g.query();
while(g.next()) {
g.work_notes = worknote;
g.update(); }
}
}
Let me know if it works! Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2017 08:01 AM
Hi Wade,
On which table have you written this inbound action?
What is the setting for stop processing and what is the order?
Do you have any inbound action written on the same table with a lower order and stop processing flag set to true?
~@$#
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2017 08:09 AM
Sorry, inbound table is sysapproval_approver. No, no stop processing markers on any actions, and this action is 99 where all other actions are default 100.
I have tested this and I can update any field with the same inbound email action, but using text values only (i.e. g.work_notes = 'Update with Text.';)
But when I try to update using email.body_text, I get nothing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2017 08:49 AM
gs.include('validators');
if (current.getTableName() == "sysapproval_approver") {
var curRec = current.document_id; //associated TASK Number to find related RFE
if (gs.hasRole("u_request_for_expenditure_user")) {
if (email.subject.indexOf("Comments for Finance") >= 0) {
var worknote = "reply from: " + email.origemail + "\n\n" + email.body_text; }
var g = new GlideRecord('u_request_for_expenditure'); // find related RFE for update
g.addQuery('sys_id', curRec);
g.query();
while(g.next()) {
g.work_notes = worknote;
g.update(); }
}
}
Your variable is declared in that if statement block. Try the code listed below and see if it works.
gs.include('validators');
if (current.getTableName() == "sysapproval_approver") {
var curRec = current.document_id; //associated TASK Number to find related RFE
var worknote = ''; //Added this line
if (gs.hasRole("u_request_for_expenditure_user")) {
if (email.subject.indexOf("Comments for Finance") >= 0) {
var worknote += "reply from: " + email.origemail + "\n\n" + email.body_text; }
var g = new GlideRecord('u_request_for_expenditure'); // find related RFE for update
g.addQuery('sys_id', curRec);
g.query();
while(g.next()) {
g.work_notes = worknote;
g.update(); }
}
}
Let me know if it works! Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2017 09:22 AM
Not sure why this would make a difference, however........ success!
Thanks a bunch!