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)

Render data on HTML WebPage in the CRM Form

(1) ShareShare
ReportReport
Posted on by 314

Hello All,

I have get data using Javascript Web API in mscrm, It is successfully getting my required data, and I have checked it through alerts. Now, what I want is I want to display this data on the HTML Webresouce.  For this I have created a Html web resource in crm entity form i need to display the data get from web api in the HTML Webresource, How can I do it?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mr Ramzy GHRIBI Profile Picture
    345 on at
    RE: Render data on HTML WebPage in the CRM Form

    Hi,

    you need to create a listner in you web ressource .

    Please try this code:

    In CRM Form :

    var message ={ 'param1': value ,'param2' : value };

    var iFrame = Xrm.Page.ui.controls.get('WebResourceName').getObject();

     iFrame.contentWindow.postMessage({'param1': value}, '*');

    In your HTML web ressource :

    if (window.addEventListener) {

       window.addEventListener("message", onMessage, false);

    }

    else if (window.attachEvent) {

       window.attachEvent("onmessage", onMessage, false);

    }

    function onMessage(event) {

       var data = event.data;

    for(var propertyName in event) {

      console.log(event[propertyName]);

    }

    community.dynamics.com/.../using-window-postmessage-to-interact-with-iframe-in-crm-form

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Render data on HTML WebPage in the CRM Form

    Hi Ishan ,

    Where did you execute the Web API ? How you are displaying the HTML web resource ? is it inside form or in a popup?

    I would suggest to execute the Web API in the html Web Resource itself , or may be take the JavaScript web resource file reference in the HTML page.

    If you execute Web API request inside HTML then you will get data directly in your HTML web resource and inside on success method do your operation with the data.

  • Ishan Sharma Profile Picture
    314 on at
    RE: Render data on HTML WebPage in the CRM Form

    Hi Goutam,

    what i have done is I have Created 2 Web Resources.

    First Web resource : Type script(JScript) Here I have written web api to get the data, This is working.

    Second Webresource : Type - webpage(Html) Here I have created structure like added  header and paragraph, Here I would like to show the Data(get from Web Api script written in First web resource) as well, but How can I do that?

    According to you I should write the web api code in second web resource itself? but if I do so than How will I call my script and what will be the Event?

    For example till now what I have done is, simply attach the  javascript in web resource then we link the web resource to Crm form properties then we set the Event like Onload and Onsave after this we write the function name that is called.

    Similarly, How can I do all these? Please share the sample code if you have or reference link. I will help me a lot.  

    Thank you so much

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Render data on HTML WebPage in the CRM Form

    Hi Ishan,

    You can execute javascript from your html web resource as well. So you do not need separate javascript file for web api call.

    Just add script tag inside your <body> of html.

    <body>

    <span id="YourElement">

    ---

    </span>

    <script type="text/javascript">

    //Your javascript goes here  e.g.

    //you can set html tag in javascript as

    document.getElementById("YourElement").innerHTML = 1 ; //You can set your webapi response here.

    </script>

    Thanks,

    Shoaib

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Render data on HTML WebPage in the CRM Form

    Hi Ishan ,

    You can use jQuery document.ready method inside html.

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at
    RE: Render data on HTML WebPage in the CRM Form

    Hi Ishan,

    You can add your js web resource to your html web resource by using script src...

    If you need to access properties of the parent CRM form page, you can use parent.Xrm.Page.getAttribute(...)

    Besides that, any other custom logic that you need to write (such as accessing Web Api), you can do it your script file directly using JavaScript and Web Api.

    Hope this helps.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Render data on HTML WebPage in the CRM Form

    Hi Ishan,

    In addition you can also store the API result in a global array object  in the JS web resource and access it from HTML web resource.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans