From 83c390baf2f9f999eb4cd7d18cf4bb4521522795 Mon Sep 17 00:00:00 2001 From: chaitaliKundu Date: Sat, 18 Oct 2025 11:06:04 +0530 Subject: [PATCH 1/4] 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/4] 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 b07490e62e1ef2c3eb140086f6eb732121142f33 Mon Sep 17 00:00:00 2001 From: chaitaliKundu Date: Sat, 18 Oct 2025 11:31:01 +0530 Subject: [PATCH 3/4] README.md --- .../Business Rules/Generate pdf/README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Server-Side Components/Business Rules/Generate pdf/README.md diff --git a/Server-Side Components/Business Rules/Generate pdf/README.md b/Server-Side Components/Business Rules/Generate pdf/README.md new file mode 100644 index 0000000000..22cf69fff0 --- /dev/null +++ b/Server-Side Components/Business Rules/Generate pdf/README.md @@ -0,0 +1,19 @@ +#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 1076e5d2b2e8b73e48f6755e8e7906b8cdbcf0f6 Mon Sep 17 00:00:00 2001 From: chaitaliKundu Date: Sat, 18 Oct 2025 11:31:53 +0530 Subject: [PATCH 4/4] letterPdf.js --- .../Business Rules/Generate pdf/letterPdf.js | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Server-Side Components/Business Rules/Generate pdf/letterPdf.js diff --git a/Server-Side Components/Business Rules/Generate pdf/letterPdf.js b/Server-Side Components/Business Rules/Generate pdf/letterPdf.js new file mode 100644 index 0000000000..7b80a2ff3e --- /dev/null +++ b/Server-Side Components/Business Rules/Generate pdf/letterPdf.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);