- 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 09:26 AM
that's because the scope of worknotes variable was limited to if block.
must appreciate the keen eyes of Harman...Like it!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2017 08:50 AM
It should just work. Just to fiddle around, have you tried -
replacing body_text with body_html
set comments/worknotes using field action instead of script