BCM - generatePlanAssetDependencies

b__DirleneS
Tera Expert

I am working on a PDF plan generated in ServiceNow, and I need to customize the output by removing any fields or text strings associated with : None.

 

Here is an example of the current OOB output:

 
RTO: 8 Hours
RPO: 8 Hours
Recovery tier: None
BIA: None
Primary source: Downstream dependency in BIA
Relationship source: Impact analysis:
Required Recovery Timeframe: None
Required Data Backup: None

 

And here is the desired output after modification:

 
text
RTO: 8 Hours
RPO: 8 Hours
Primary source: Downstream dependency in BIA Relationship
source: Impact analysis
 

I am using the out-of-the-box (OOB) PDF generation functionality, and I would like to know:

  1. Is it possible to modify the PDF plan to exclude fields with None dynamically?

  2. What are the steps or scripts required to achieve this customization?

Any guidance, examples, or best practices for achieving this would be greatly appreciated!

Thank you in advance!

#BCM



3 ACCEPTED SOLUTIONS

Vishal Jaswal
Giga Sage

Hello @b__DirleneS 

I would advise you to go with your own custom Plan pdf template. The value of System property (sys_properties.LIST) "sn_bcp.default_pdf_plan_template" decides the default Plan pdf template which you can change to your own custom one or Navigate to All > Business Continuity > General Administration > Properties


Why custom one -- You will get more flexibility to modify it as the oob one will not allow you to modify or will show in skipped updates or may cause issues during BCM update later.

Step#1: Table: sn_doc_template --> Clone the oob template, rename what you want and then use your own template_script
Step#2: Create your own template script --> Table: sn_doc_template_script --> This is where you can use your own custom logic to get rid of all None value fields as shown below:

(function runTemplateScript(target /* GlideRecord for target task */) {

    var planGr = new GlideRecord('sn_bcp_plan');
    planGr.get(target.plan);

    function getPlanDetailsTable(planRecord) {
        var tableBodyContent = '';
        var tableOpenTag = '<table cellpadding="5" class="detail-section-table">';
        var tableCloseTag = '</table>';
        var description = "<p>" + planRecord.getDisplayValue('description') + "</p>";
        var status = (target.plan.state == "archived" || target.plan.state == "approved") ? "Approved" : "Draft";

        function addTableRow(label, value) {
            if (value && value !== "None") { // Exclude "None" and empty values
                return '<tr><th>' + label + '</th><td>' + value + '</td></tr>';
            }
            return ''; // Skip row if value is "None"
        }

        tableBodyContent = description +
            addTableRow('Status', status) +
            addTableRow('RTO', planRecord.getDisplayValue('rto')) +
            addTableRow('Plan Owner', planRecord.getDisplayValue('plan_owner')) +
            addTableRow('RPO', planRecord.getDisplayValue('rpo')) +
            addTableRow('Created', planRecord.getDisplayValue('sys_created_on')) +
            addTableRow('Expires', planRecord.getDisplayValue('expires')) +
            addTableRow('Template', planRecord.getDisplayValue('template')) +
            addTableRow('Type', planRecord.getDisplayValue('type'));

        var resultTable = tableOpenTag + '<tbody>' + tableBodyContent + '</tbody>' + tableCloseTag + '<br/>';
        return resultTable;
    }

    return getPlanDetailsTable(planGr);

})(target);

 


Hope that helps!

View solution in original post

Thank you so much 

View solution in original post

Hello @b__DirleneS  If you find my answer as an appropriate solution, then requesting you to please mark it as accepted solution so that it will help and benefit fellow ServiceNow learners like us.


Hope that helps!

View solution in original post

3 REPLIES 3

Vishal Jaswal
Giga Sage

Hello @b__DirleneS 

I would advise you to go with your own custom Plan pdf template. The value of System property (sys_properties.LIST) "sn_bcp.default_pdf_plan_template" decides the default Plan pdf template which you can change to your own custom one or Navigate to All > Business Continuity > General Administration > Properties


Why custom one -- You will get more flexibility to modify it as the oob one will not allow you to modify or will show in skipped updates or may cause issues during BCM update later.

Step#1: Table: sn_doc_template --> Clone the oob template, rename what you want and then use your own template_script
Step#2: Create your own template script --> Table: sn_doc_template_script --> This is where you can use your own custom logic to get rid of all None value fields as shown below:

(function runTemplateScript(target /* GlideRecord for target task */) {

    var planGr = new GlideRecord('sn_bcp_plan');
    planGr.get(target.plan);

    function getPlanDetailsTable(planRecord) {
        var tableBodyContent = '';
        var tableOpenTag = '<table cellpadding="5" class="detail-section-table">';
        var tableCloseTag = '</table>';
        var description = "<p>" + planRecord.getDisplayValue('description') + "</p>";
        var status = (target.plan.state == "archived" || target.plan.state == "approved") ? "Approved" : "Draft";

        function addTableRow(label, value) {
            if (value && value !== "None") { // Exclude "None" and empty values
                return '<tr><th>' + label + '</th><td>' + value + '</td></tr>';
            }
            return ''; // Skip row if value is "None"
        }

        tableBodyContent = description +
            addTableRow('Status', status) +
            addTableRow('RTO', planRecord.getDisplayValue('rto')) +
            addTableRow('Plan Owner', planRecord.getDisplayValue('plan_owner')) +
            addTableRow('RPO', planRecord.getDisplayValue('rpo')) +
            addTableRow('Created', planRecord.getDisplayValue('sys_created_on')) +
            addTableRow('Expires', planRecord.getDisplayValue('expires')) +
            addTableRow('Template', planRecord.getDisplayValue('template')) +
            addTableRow('Type', planRecord.getDisplayValue('type'));

        var resultTable = tableOpenTag + '<tbody>' + tableBodyContent + '</tbody>' + tableCloseTag + '<br/>';
        return resultTable;
    }

    return getPlanDetailsTable(planGr);

})(target);

 


Hope that helps!

Thank you so much 

Hello @b__DirleneS  If you find my answer as an appropriate solution, then requesting you to please mark it as accepted solution so that it will help and benefit fellow ServiceNow learners like us.


Hope that helps!