Skip to main content

Notifications

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

How to load jsPDF as a dependency for other javascript file to use?

(0) ShareShare
ReportReport
Posted on by 105

I want to add a custom button to the grid that when pressed will call my javascript function that relies on jspdf

I created 2 new web resources

  1. using https://github.com/parallax/jsPDF/blob/master/dist/jspdf.es.js 
  2. My custom javascript utilizes jsPDF

I use Ribbon Workbench to add 2 actions for the command.

  1. The 1st action calls the jspdf webresource with "isNaN" function name
  2. The 2nd action calls my js webresource with my function name.

When I click on the custom button, I get javascript error "ReferenceError: jsPDF is not defined" on the line "let pdf = new jsPDF("p", "pt", "a4");" it seems that jsPDF is not being loaded at all?

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to load jsPDF as a dependency for other javascript file to use?

    Hi Kirk T,

    Which is your version of Dynamics 365? Is it V9?

    If yes, you could add your jspdf web resource to another JS web resource's dependence like this:

    pastedimage1639638726380v1.png

    Below is my test:

    My person.js:

    function Person(name,age) {
        this.name = name;
        this.age = age;
    }

    Another JS web resource:

    function preSetText(executionContext){
    var someone = new Person("someone",20);
    console.log(someone);
    }

    Add a button on my account form with another JS as command:

    pastedimage1639638985861v2.png

    Result:

    pastedimage1639639075841v3.gif

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,074 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,900 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans