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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Best way to call JS functions from HTML web resource in v.9

(0) ShareShare
ReportReport
Posted on by 71

Hello,

I have a case, where I have to make custom pop up message, allowing user to select between sending mail without attachments (and on button click the workflow sending mail should be fired), or opening mail form (on button click) and sending mail manually. What is the best way to achieve this? Is it even possible to run JS from HTML not in a form container now?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Kalpavruksh D365 CoE Profile Picture
    2,545 on at
    Hi,
    You can call the script function from HTML web resource.
    In HTML page do refer to the script file location in Script tag.
    Refer below code:
    <!DOCTYPE html>
    <html>
    <head>
        <title>Allocate LED for Match</title>
        <meta charset="utf-8" />
    </head>
    <body>
    <script type="text/javascript" src="../WebResources/pro_TestServices.js"></script>
     
    </body>
    </html>

    And in Script file write script function code:
    Refer code below:
    // pro_TestServices.js
    function Testfunction()
    { alert("test function");
    }
    On button click in HTML web resource, you can call the function from TestServices.js script file.
  • Suggested answer
    Pawar Pravin  Profile Picture
    5,237 on at

    Hi Pocia,

    Do you want to call JS function in CRM which is inside HTML web resource ?

    Please refer below code for your reference:

    Xrm.Page.getControl("WebResource_nameofresource").getObject().contentWindow.window.YourFunctionName();

  • Pocia Profile Picture
    71 on at

    Hi Pravin,

    No I want to call function in HTML web resource from separate JS web resource (function is placed in this JS file)

  • Suggested answer
    Pawar Pravin  Profile Picture
    5,237 on at

    Hi Pocia,

    You can use same approach to call JS function in HTML from another JS file :

    Xrm.Page.getControl("WebResource_nameofresource").getObject().contentWindow.window.YourFunctionName();

    https://ibb.co/pbnSK1V

  • Community Member Profile Picture
    on at

    Thank you for the entire discussion, as I was also looking forward for the same query. Besides, if you want any technical support you can also visit www.errorcodeexpert.com/.../ and find the best solution to your any further queries.

  • Pocia Profile Picture
    71 on at

    Thank you all for your responses. I managed to get it working.

    For pop-up html resources, you should prefix Xrm.Page with window.opener to get attributes from entity

    For html web resources embedded on form, you should prefix Xrm.Page with window.parent

    reference: docs.microsoft.com/.../important-changes-coming

  • Suggested answer
    Pawar Pravin  Profile Picture
    5,237 on at

    Great,

    Please mark your answer is verified so that it could be helpful for others

  • Suggested answer
    Indira securities Profile Picture
    5 on at

    Very interesting details you have noted, thank you for posting.

    <a href="www.indiratrade.com/.../hdfc-bank">HDFC bank share price</a>,

    <a href="www.indiratrade.com/.../tata-steel">Tata Steel Share Price</a>,

    <a href="www.indiratrade.com/.../dlf">DLF share price</a>,

    <a href="www.indiratrade.com/.../sbi">SBI share price</a>,

    <a href="www.indiratrade.com/.../itc">ITC Share Price</a>

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans