How do I associate my CUSTOM PDF template to the "Generate PDF" UI button?

Adrian Weber1
Tera Contributor

My end-user has starting talking about customizing the PDF that is generated for Plans, BIA's, etc.  Company logo, a few other things, etc... That part, no problem.  

I've made a copy of the OOTB PDF template, and customized the copy... but now, how do I get that copy to be associated with the "Generate PDF" button?  Seems like the button is associated with the sys_id of the OOB template.  

 

As an additional twist, the same end-user is thinking he would like have different templates for different types of plans... so, a Disaster Recovery plan, a Business Continuity Plan, etc... is it even possible to make that button select from a list of PDF's?  

1 ACCEPTED SOLUTION

Ramu Neelam
Giga Expert

Hello @Adrian Weber1,

The answer to your first question "How do you link the new template to Generate PDF?" - This is possible by modifying the appropriate GeneratePDFUtil script.

 

Here are the steps to modify BIA PDF generation.

  • Create your own PDF Template (Document Templates > All Document Templates) and open the OOTB “BIA PDF Template”
  • Click the Copy button and rename it as "NR BIA PDF Template" and modify the body according to the client requirement.
  • Once updated then hit the publish button.

 

Go to Script includes (System Definition > Script Includes) and search for “GenerateBiaPdfUtil” and replace the existing script with the below given script. The reason why we are updating the script is because the "Generate PDF" button UI Action in BIA record uses the "GenerateBiaPdfUtilBase" and "GenerateBiaPdfUtil" script includes. Since we want to use our own PDF template instead of OOTB PDF template, we need to override the method "getPDFTemplateName" in the "GenerateBiaPdfUtil" script.

 

var GenerateBiaPdfUtil = Class.create();

GenerateBiaPdfUtil.prototype = Object.extendsObject(GenerateBiaPdfUtilBase, {

 

    /** Override base class functions here. **/

 getPDFTemplateName: function() {

        return "NR BIA PDF Template";

    },

    type: 'GenerateBiaPdfUtil'

});

 

Save the Script and go to any existing BIA record and click the “Generate PDF” button and verify whether the changes appeared according to the new template or not.

 

The response, to your second question about the possibility of having different templates for different types of plans is absolutely possible and all you need to do is just update the Generate PDF script and if needed override some of the methods in “Generate PDF Util” scripts.

 

Please let me know if you have any questions.

 

Thanks,

Ramu Neelam

View solution in original post

1 REPLY 1

Ramu Neelam
Giga Expert

Hello @Adrian Weber1,

The answer to your first question "How do you link the new template to Generate PDF?" - This is possible by modifying the appropriate GeneratePDFUtil script.

 

Here are the steps to modify BIA PDF generation.

  • Create your own PDF Template (Document Templates > All Document Templates) and open the OOTB “BIA PDF Template”
  • Click the Copy button and rename it as "NR BIA PDF Template" and modify the body according to the client requirement.
  • Once updated then hit the publish button.

 

Go to Script includes (System Definition > Script Includes) and search for “GenerateBiaPdfUtil” and replace the existing script with the below given script. The reason why we are updating the script is because the "Generate PDF" button UI Action in BIA record uses the "GenerateBiaPdfUtilBase" and "GenerateBiaPdfUtil" script includes. Since we want to use our own PDF template instead of OOTB PDF template, we need to override the method "getPDFTemplateName" in the "GenerateBiaPdfUtil" script.

 

var GenerateBiaPdfUtil = Class.create();

GenerateBiaPdfUtil.prototype = Object.extendsObject(GenerateBiaPdfUtilBase, {

 

    /** Override base class functions here. **/

 getPDFTemplateName: function() {

        return "NR BIA PDF Template";

    },

    type: 'GenerateBiaPdfUtil'

});

 

Save the Script and go to any existing BIA record and click the “Generate PDF” button and verify whether the changes appeared according to the new template or not.

 

The response, to your second question about the possibility of having different templates for different types of plans is absolutely possible and all you need to do is just update the Generate PDF script and if needed override some of the methods in “Generate PDF Util” scripts.

 

Please let me know if you have any questions.

 

Thanks,

Ramu Neelam