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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Custom button javascript

(0) ShareShare
ReportReport
Posted on by 165

Hi all. I created a custo html button and added it to my form. I added a script tag in the head tag of the html with a script to be executed. How do i load the script on the form before calling it on the button click. Kindly assist. Below is the script

<html><head>
  <title>ApproveInvoice</title>
  <style type="text/css">
   body,html {
    height:95%;
    width:100%;
    margin:0;
    padding:0;
   }
  </style>
 <meta charset="utf-8">
 </head><body>
  <div id="buttons_main">
   <script type="text/JavaScript">
       function ApproveInvoice_click() {
           window.parent.ApproveInvoice();
       }
   </script>
   <button class="ms-crm-Button" onclick="ApproveInvoice_click();">Approve Invoice</button>
  </div>
 
</body></html>

*This post is locked for comments

I have the same question (0)
  • Frank Ewans Profile Picture
    165 on at
    RE: Custom button javascript

    Thanks Lucas. Solved my issue

  • Suggested answer
    Bruno Lucas Profile Picture
    5,421 on at
    RE: Custom button javascript

    Hi,

    You can load the script as a JavaScript resource and reference the JavaScript resource on your HTML:

    Referencing a script web resource from a webpage web resource

    All web resources can use relative URLs to reference each other. In the following example, for the webpage web resource new_/content/contentpage.htm to reference the script web resource new_/scripts/myScript.js, add the following HTML code to the head element of new_/content/contentpage.htm.

    <script type="text/jscript" src="../scripts/myScript.js"></script>

    To reference a script from a different publisher, the path must include the customization prefix for that publisher. For example, for the new_/content/contentpage.htm page to reference the MyIsv_/scripts/customscripts.js page, the src attribute value should be ../../MyIsv_/scripts/customscripts.js.

    msdn.microsoft.com/.../gg309414.aspx

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Aric Levin - MVP Profile Picture

Aric Levin - MVP 2 Moderator

#2
MA-04060624-0 Profile Picture

MA-04060624-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans