Skip to content

Commit a4bda17

Browse files
Reply Inbound email action on sc_task (#2245)
* README.md * pdfletter.js * Delete Server-Side Components/Business Rules/PdfletterGeneration directory * README.md * reply.js
1 parent 99a9a56 commit a4bda17

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#contribution
2+
3+
An SC Task is assigned to the requester. When the requester replies with the following format:
4+
5+
Are you good to proceed? Yes
6+
Date: 20-10-2025
7+
8+
…the reply information is automatically extracted and populated into custom fields on the SC Task record.
9+
10+
Two custom fields have been created for this purpose:
11+
12+
Date:20/10/2025
13+
14+
Process: Yes
15+
16+
Inbound Email Action:
17+
---------------------
18+
Created Reply Inbound email action on sc_task table.
19+
Table - sc_task
20+
Type - Reply
21+
Condition - Subject : has been assigned for Satiesfiction.
22+
23+
Objective of the code:
24+
-----------------------
25+
26+
When a requester replies to an SC Task email with specific text (like "Are you good to Processed? Yes" and "Date: 2025-10-20"), this script:
27+
28+
Updates task comments with the reply
29+
Uses regex to search for date and tries to extract a Yes/No response from a line like:
30+
31+
Are you good to proceed? Yes
32+
Date: 20-10-2025
33+
34+
Populates two custom fied the SC Task (u_date, u_processed)
35+
36+
Sets the task's state to 3 (Completed) once reply done & extract and auto population performed.
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)