Skip to content

Commit edc932e

Browse files
replytask.js
1 parent 56b983e commit edc932e

File tree

1 file changed

+62
-0
lines changed
  • Server-Side Components/Inbound Actions/Reply TASK

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//Reply Inbound Email Action
2+
// Table - sc_task
3+
4+
// Type - Reply
5+
//Order - 100
6+
7+
// Condition - Subject - has been assigned for Satiesfiction
8+
9+
//Script
10+
11+
gs.include('validators');
12+
13+
if (current.getTableName() == "sc_task") {
14+
15+
// Update comments on current sc_task and save it
16+
current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
17+
18+
19+
// Parse Date (YYYY-MM-DD)
20+
var DateMatch = email.body_text.match(/Date:\s*([\d]{4}-[\d]{2}-[\d]{2})/i);
21+
22+
var DateStr = DateMatch ? DateMatch[1] : null;
23+
24+
// Parse "Are you good to Processed "
25+
var process = email.body_text.match(/Are you good to Processed\?\s*:\s*(Yes|No)/i);
26+
27+
var proceeStr = process ? procee.match[1].toLowerCase() : null;
28+
29+
30+
if (DateStr) {
31+
var gd = new GlideDate();
32+
gd.setValue(DateStr);
33+
parentCaseGR.setValue('u_date', gd); // replace with your field
34+
35+
}
36+
37+
// Update "Are you good to Process" if found
38+
if (proceeStr) {
39+
40+
var normalizedInput = proceeStr.toLowerCase();
41+
42+
var choiceValue = null;
43+
if (normalizedInput === 'yes') {
44+
choiceValue = '1'; // choice value for Yes
45+
} else if (normalizedInput === 'no') {
46+
choiceValue = '2'; // choice value for No
47+
}
48+
49+
if (choiceValue) {
50+
parentCaseGR.setValue('u_processed', choiceValue);
51+
52+
}
53+
}
54+
55+
56+
57+
}
58+
59+
current.state = 3;
60+
current.update();
61+
}
62+

0 commit comments

Comments
 (0)