web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / How to refer Javascrip...
Power Pages
Unanswered

How to refer Javascript library in Basic Form

(0) ShareShare
ReportReport
Posted on by 96

I have an advanced form and in one of the advanced form steps, I have a subrid which allows me to add  / edit child records. The subgrid opens a basic form.In this basic form I have some javascript. I also want to refer a javascript libarary (attached as a web-file), and it's functions in this basic form. However, I don't know what's the correct syntex to refer to this library. I tried adding it as 

<script type="text/javascript" src="/commonfunctions.js"></script>
 
but it does not work. Note that this library is also being referenced in the advanced form step. I have no issues on that page because I am referencing the library in the web template for the advanced form.
Categories:
  • oliver.rodrigues Profile Picture
    9,482 Most Valuable Professional on at

    Hi, how common are these "commongunctions.js"? 

    if they are common throughout all your Advanced Form, I would add this reference to the Web Page related to the Adv Form

    if they are even more high level than that, and would be used your entire Site, I would say to reference in the Content Snippet Tracking Code

  • Manish R Sharma Profile Picture
    96 on at

    Hi @OliverRodrigues , I have added it to the web page related to the advanced form, but when I try to call the function from the basic form (modal form on the subgrid of the advanced form), I  get an error:
    Uncaught ReferenceError: CBR is not defined

    I am calling the function like this:

    CBR.Common.dateValidator("cbr_dateofbirth", dateofbirth, "lessthan", today,  "Date of Birth cannot be a future date.");
    If I call this same function on the advanced form step (which has the subgrid), I do not get an error. It seem s that somehow the modal form cannot get the reference of the javascript file from the advanced form web template, or maybe my syntax is wrong. Any suggestions ?
  • Fubar Profile Picture
    17 Super User 2026 Season 1 on at

    Can't remember if doing it in the Page works or not, but worst case you can dynamically write it via JQuery in the provided JavaScript section

     

     

    var script = document.createElement('script');
    script.src='/yourfile.js';
    script.type = 'text/javascript';
    document.getElementsByTagName('head')[0].appendChild(script);

     

     

     

    You can also probably embed a dataverse Web Resource (that contains the script src tag.) on the entity/basic form

     

    Edit: if script src is in the Web Page content then think it may actually be a scope thing, if inside a document ready try accessing the function using parent.parent.yourfunctionname (or if not in doc ready this.parent.parent.yourfunctioname)

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Pages

#1
Mohsin Ali Profile Picture

Mohsin Ali 35

#2
M Bilal Khan Profile Picture

M Bilal Khan 29

#3
11manish Profile Picture

11manish 21 Super User 2026 Season 2

Last 30 days Overall leaderboard