File tree Expand file tree Collapse file tree 2 files changed +87
-0
lines changed
Server-Side Components/Inbound Actions/Reply Task Expand file tree Collapse file tree 2 files changed +87
-0
lines changed Original file line number Diff line number Diff line change 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.
Original file line number Diff line number Diff line change 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 ( / D a t e : \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 ( / A r e y o u g o o d t o P r o c e s s e d \? \s * : \s * ( Y e s | N o ) / 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+ }
You can’t perform that action at this time.
0 commit comments