Skip to content

Commit 6ec4a2b

Browse files
reply.js
1 parent 459b7e9 commit 6ec4a2b

File tree

1 file changed

+51
-0
lines changed
  • Server-Side Components/Inbound Actions/Reply Task

1 file changed

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

0 commit comments

Comments
 (0)