PDF Generation business rule duplication
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 06:14 AM
Hello,
I am task to add something to this PDF generation BR to stop this business rule from recreating PDFs when a comment or approval status is changed. Please advise
attachmentSysID = gs.getProperty('x_g_dh5_ccht.CCHT fillable pdf');
if (current.alien_number == "") {
pdfName = 'Notification of Approved Continued Presence ' + current.secondary_entry_afile_number + '.pdf';
} else if (current.alien_number != "") {
pdfName = 'Notification of Approved Continued Presence ' + current.alien_number.replace('A-', '') + '.pdf';
}
var fieldMap = new Object();
//fieldMap["jsonForPDF"] = 'CP End Date:'+ current.record_expiration_date+"";
// getting approval date
// var approvalGr = new GlideRecord('sysapproval_approver');
// approvalGr.addQuery('sysapproval', current.sys_id);
// approvalGr.addQuery('state', 'approved');
// approvalGr.query();
// if (approvalGr.next()) {
// var approvalDate = approvalGr.sys_updated_on.getDisplayValue();
// }
// not created date
// var createdOn = current.sys_created_on+'';
var gdt4 = new GlideDate();
current.cp_start_date= new GlideDate();
current.update();
gdt4.setValue(current.cp_start_date + "");
var fromDate2 = gdt4.getByFormat('MM/dd/yyyy') + "";
var gdt = new GlideDate();
gdt.setValue(current.record_expiration_date + "");
var toDate = gdt.getByFormat('MM/dd/yyyy') + "";
var gdt3 = new GlideDate();
gdt3.setValue(current.ext_date_of_birth + "");
var birthDate = gdt3.getByFormat('MM/dd/yyyy') + "";
//fieldMap["jsonForPDF"] = 'CP End Date:'+ current.record_expiration_date+"";
fieldMap["from_date"] = fromDate2;
fieldMap["to_date"] = toDate;
fieldMap["victim_anumber"] = current.alien_number.replace('A-', '') + "";
fieldMap["victim_first_name"] = current.extention_v_first + "";
fieldMap["victim_last_name"] = current.extention_v_last_name + "";
fieldMap["victim_dob"] = birthDate;
fieldMap["victim_anumber"] = current.alien_number + "";
fieldMap["victim_country"] = current.ext_country_of_birth.getDisplayValue() + "";
fieldMap["victim_trafficking"] = current.type_of_trafficking + "";
fieldMap["case_agent"] = current.lead_officer_first_name + " " + current.lead_officer_last_name + "";
fieldMap["case_phone"] = current.ldc_phone_number + "";
//if (current.phone_extension != "") {
// fieldMap["case_phone"] = current.ldc_phone_number + " ext " + current.phone_extension + "";
//}
fieldMap["case_email"] = current.lead_officer_email_address + "";
fieldMap["assistance_specialist"] = current.vwc_first_name + " " + current.vwc_last_name + "";
fieldMap["assistance_phone"] = current.vwc_daytime_phone_number + "";
if (current.victim_relations_phone_ext != "") {
fieldMap["assistance_phone"] = current.vwc_daytime_phone_number + " ext " + current.vwc_ext + "";
}
fieldMap["assistance_email"] = current.vwc_email_address + "";
//fieldMap["Sponsoring Law Enforcement Agencies"]="";
var flatten = new Object();
flatten["FlattenType"] = "fully_flatten";
var v = new sn_pdfgeneratorutils.PDFGenerationAPI;
var result = v.fillDocumentFieldsAndFlatten(fieldMap, attachmentSysID, 'x_g_dh5_ccht_ccht_task', current.getValue('sys_id'), pdfName, flatten);
current.approved_record_sysid = result.attachment_id;
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 06:37 AM
Hi @BenjaminY
You can change the trigger conditions based on fields which will be changed. I am assuming that "Request type" field value will not be changed. Hence, you can update conditions based on Record status.
You can adjust the condition like
Record Status -- changes to -- Approved
Approved record sysid -- is empty
Record expiration date -- is not empty
Request type --is -- extension