diff --git a/Server-Side Components/Inbound Actions/Reply Task/README.md b/Server-Side Components/Inbound Actions/Reply Task/README.md new file mode 100644 index 0000000000..b2877f6aef --- /dev/null +++ b/Server-Side Components/Inbound Actions/Reply Task/README.md @@ -0,0 +1,36 @@ +#contribution + +An SC Task is assigned to the requester. When the requester replies with the following format: + +Are you good to proceed? Yes +Date: 20-10-2025 + +…the reply information is automatically extracted and populated into custom fields on the SC Task record. + +Two custom fields have been created for this purpose: + +Date:20/10/2025 + +Process: Yes + +Inbound Email Action: +--------------------- +Created Reply Inbound email action on sc_task table. +Table - sc_task +Type - Reply +Condition - Subject : has been assigned for Satiesfiction. + +Objective of the code: +----------------------- + +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: + +Updates task comments with the reply +Uses regex to search for date and tries to extract a Yes/No response from a line like: + +Are you good to proceed? Yes +Date: 20-10-2025 + +Populates two custom fied the SC Task (u_date, u_processed) + +Sets the task's state to 3 (Completed) once reply done & extract and auto population performed. diff --git a/Server-Side Components/Inbound Actions/Reply Task/reply.js b/Server-Side Components/Inbound Actions/Reply Task/reply.js new file mode 100644 index 0000000000..4321a0617d --- /dev/null +++ b/Server-Side Components/Inbound Actions/Reply Task/reply.js @@ -0,0 +1,51 @@ +gs.include('validators'); + +if (current.getTableName() == "sc_task") { + + // Update comments on current sc_task and save it + current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text; + + + // Parse Date (DD-MM-YYYY) + var DateMatch = email.body_text.match(/Date:\s*([\d]{2}-[\d]{2}-[\d]{4})/i); + + var DateStr = DateMatch ? DateMatch[1] : null; + + // Parse "Are you good to Processed " + var process = email.body_text.match(/Are you good to Processed\?\s*:\s*(Yes|No)/i); + + var proceeStr = process ? procee.match[1].toLowerCase() : null; + + + if (DateStr) { + var gd = new GlideDate(); + gd.setValue(DateStr); + current.setValue('u_date', gd); // replace with field + + } + + // Update "Are you good to Process" if found + if (proceeStr) { + + var normalizedInput = proceeStr.toLowerCase(); + + var choiceValue = null; + if (normalizedInput === 'yes') { //converting Yes/ No field to 1 , 2 as per backend field sc_task + choiceValue = '1'; // choice value for Yes + } else if (normalizedInput === 'no') { + choiceValue = '2'; // choice value for No + } + + if (choiceValue) { + current.setValue('u_processed', choiceValue); //set value in custom field + + } + } + + + + } + + current.state = 3; + current.update(); +}