From 83c390baf2f9f999eb4cd7d18cf4bb4521522795 Mon Sep 17 00:00:00 2001 From: chaitaliKundu Date: Sat, 18 Oct 2025 11:06:04 +0530 Subject: [PATCH 1/5] README.md --- .../PdfletterGeneration/README.md | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Server-Side Components/Business Rules/PdfletterGeneration/README.md diff --git a/Server-Side Components/Business Rules/PdfletterGeneration/README.md b/Server-Side Components/Business Rules/PdfletterGeneration/README.md new file mode 100644 index 0000000000..6ba5d77aa5 --- /dev/null +++ b/Server-Side Components/Business Rules/PdfletterGeneration/README.md @@ -0,0 +1,22 @@ +#Contribution + +The Business Rule is triggered after an update on the sn_hr_core_case table, specifically when the case state is set to "Work in Progress". This rule generates a PDF letter based on the trigerred conditions. + +Document Template created seperately. Document Template Name - PDF Letter Employee.The Document Template Sys ID is passed within the script, and the corresponding document template has been created separately (refer to the attached screenshot for reference). +Document Template -> All Document Templates - > New +As per the script, the PDF letter is generated and named using the HR case subject's name — for example: +"Letter: " + empName + ".pdf". + +Functionality - +When a fulfiller changes the case state to "Work in Progress", the PDF letter is automatically generated and attached to the HR case record. + +Business Rule Description - + +Name - pdf Letter generation +Table - sn_hr_core_case +Condition - state is "work in Progress" +Update - Check the box +When -select after + + + From 5f52a2f0d15487806c8aabf942b338412cecef38 Mon Sep 17 00:00:00 2001 From: chaitaliKundu Date: Sat, 18 Oct 2025 11:11:08 +0530 Subject: [PATCH 2/5] pdfletter.js --- .../PdfletterGeneration/pdfletter.js | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Server-Side Components/Business Rules/PdfletterGeneration/pdfletter.js diff --git a/Server-Side Components/Business Rules/PdfletterGeneration/pdfletter.js b/Server-Side Components/Business Rules/PdfletterGeneration/pdfletter.js new file mode 100644 index 0000000000..7b80a2ff3e --- /dev/null +++ b/Server-Side Components/Business Rules/PdfletterGeneration/pdfletter.js @@ -0,0 +1,32 @@ +(function executeRule(current, previous /*null when async*/ ) { + + // Add your code here + var recordId = current.sys_id.toString(); + var empName = current.subject_person; + + var templateId1 = gs.getProperty("sn_hr_core.letter"); // Document Template sysid + + + var pdfFileName1 = 'Letter:' +empName+ '.pdf'; //letter name + + + gs.info('[PDF Generation] HRC Number ' + recordId); + + try { + + var docGen1 = new sn_doc.GenerateDocumentAPI(); + docGen1.generateDocumentForTask(recordId, templateId1, pdfFileName1); + + gs.info('[PDF Generation] PDF attached to HRC: ' + recordId); + } + + + + catch (ex) { + gs.error('[PDF Generation] Failed: ' + ex.message); + } + current.setWorkflow(false); + + + +})(current, previous); From ce0dbee2eb4e335c02492d9c06820628ee6fdde9 Mon Sep 17 00:00:00 2001 From: chaitaliKundu Date: Sat, 18 Oct 2025 12:24:13 +0530 Subject: [PATCH 3/5] Delete Server-Side Components/Business Rules/PdfletterGeneration directory --- .../PdfletterGeneration/README.md | 22 ------------- .../PdfletterGeneration/pdfletter.js | 32 ------------------- 2 files changed, 54 deletions(-) delete mode 100644 Server-Side Components/Business Rules/PdfletterGeneration/README.md delete mode 100644 Server-Side Components/Business Rules/PdfletterGeneration/pdfletter.js diff --git a/Server-Side Components/Business Rules/PdfletterGeneration/README.md b/Server-Side Components/Business Rules/PdfletterGeneration/README.md deleted file mode 100644 index 6ba5d77aa5..0000000000 --- a/Server-Side Components/Business Rules/PdfletterGeneration/README.md +++ /dev/null @@ -1,22 +0,0 @@ -#Contribution - -The Business Rule is triggered after an update on the sn_hr_core_case table, specifically when the case state is set to "Work in Progress". This rule generates a PDF letter based on the trigerred conditions. - -Document Template created seperately. Document Template Name - PDF Letter Employee.The Document Template Sys ID is passed within the script, and the corresponding document template has been created separately (refer to the attached screenshot for reference). -Document Template -> All Document Templates - > New -As per the script, the PDF letter is generated and named using the HR case subject's name — for example: -"Letter: " + empName + ".pdf". - -Functionality - -When a fulfiller changes the case state to "Work in Progress", the PDF letter is automatically generated and attached to the HR case record. - -Business Rule Description - - -Name - pdf Letter generation -Table - sn_hr_core_case -Condition - state is "work in Progress" -Update - Check the box -When -select after - - - diff --git a/Server-Side Components/Business Rules/PdfletterGeneration/pdfletter.js b/Server-Side Components/Business Rules/PdfletterGeneration/pdfletter.js deleted file mode 100644 index 7b80a2ff3e..0000000000 --- a/Server-Side Components/Business Rules/PdfletterGeneration/pdfletter.js +++ /dev/null @@ -1,32 +0,0 @@ -(function executeRule(current, previous /*null when async*/ ) { - - // Add your code here - var recordId = current.sys_id.toString(); - var empName = current.subject_person; - - var templateId1 = gs.getProperty("sn_hr_core.letter"); // Document Template sysid - - - var pdfFileName1 = 'Letter:' +empName+ '.pdf'; //letter name - - - gs.info('[PDF Generation] HRC Number ' + recordId); - - try { - - var docGen1 = new sn_doc.GenerateDocumentAPI(); - docGen1.generateDocumentForTask(recordId, templateId1, pdfFileName1); - - gs.info('[PDF Generation] PDF attached to HRC: ' + recordId); - } - - - - catch (ex) { - gs.error('[PDF Generation] Failed: ' + ex.message); - } - current.setWorkflow(false); - - - -})(current, previous); From 459b7e95903dbaee28f929a2a547988ddb960afb Mon Sep 17 00:00:00 2001 From: chaitaliKundu Date: Sat, 18 Oct 2025 13:26:27 +0530 Subject: [PATCH 4/5] README.md --- .../Inbound Actions/Reply Task/README.md | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Server-Side Components/Inbound Actions/Reply Task/README.md 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. From 6ec4a2beff5e45bd2690a9cdb237d38c2b05a3ff Mon Sep 17 00:00:00 2001 From: chaitaliKundu Date: Sat, 18 Oct 2025 13:35:52 +0530 Subject: [PATCH 5/5] reply.js --- .../Inbound Actions/Reply Task/reply.js | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Server-Side Components/Inbound Actions/Reply Task/reply.js 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(); +}