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 Apps / IFrame in html web res...
Power Apps
Unanswered

IFrame in html web resource

(1) ShareShare
ReportReport
Posted on by 37

Hi hope you guys are fine.

 

I have one html web resource and I have JAVASCRIPT in this html web resource plus I have IFrame in this html web resource as well. I have inserted this html web resource on custom entity form using web resource icon menu on main form of entity.

 

On Page load when i try to access IFrame like this document.getElementById("iframeid") I get IFrame control but when I try to get IFrame using Xrm.Page.ui.controls.get("iframeid") or Xrm.Page.getControl("iframeid") i always get null. 

 

In IFrame I am loading my Canvas app, my canvas app is embeded in model driven app via iframe.

 

just to let you know , I have html iframe in html web resource like this

 

<iframe id="myid"></iframe>

 

I have 3 tabs on form and iframe is on first tab which opens bydefault on page load.

 

I do not want to use document.getElementById because MS does not recommend it when when try to publish our app to MS app source.

 

Any idea what i am doing wrong using XRM api ?

 

 

Categories:
  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @zaina 

     

    1. Try either window.parent.Xrm.Page (not recommended) or parent.Xrm.Page (better, but the below may be recommended instead)

    2. Use this example of getting form context first using this as a guide:

    //Get the value of an option set attribute
    var formContext = executionContext.getFormContext();
    var value = formContext.getAttribute("new_pagechooser").getValue(); 
    var newTarget = ""; 
    //Set the target based on the value of the option set 
    switch (value) { 
     case 100000001: 
     newTarget = https://myServer/test/pageOne.aspx; 
     break; 
     default: 
     newTarget = https://myServer/test/pageTwo.aspx; 
     break; 
    } 
    //Get the default URL for the IFRAME, which includes the 
    // query string parameters 
    var IFrame = formContext.ui.controls.get("IFRAME_test"); 
    var Url = IFrame.getSrc(); 
    // Capture the parameters 
    var params = Url.substr(Url.indexOf("?")); 
    //Append the parameters to the new page URL 
    newTarget = newTarget + params; 
    // Use the setSrc method so that the IFRAME uses the 
    // new page with the existing parameters 
    IFrame.setSrc(newTarget);

    use executionContext.getFormContext(); to get the context first for example.

    (example from here)

  • zaub Profile Picture
    37 on at

    I can not get form context because it is html web resource. I have tried both but returns null
    window.parent.Xrm.Page  or parent.Xrm.Page 

  • zaub Profile Picture
    37 on at

    just to let you know , I have html iframe in html web resource like this

     

    <iframe id="myid"></iframe>

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @zaina Does using Xrm.Page.context instead work?

  • zaub Profile Picture
    37 on at

    nope

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 Apps

#1
11manish Profile Picture

11manish 383 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 356

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard