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)

use Xrm.page in a "popup" html web resource

(0) ShareShare
ReportReport
Posted on by

Hi

I am currently making a "popup" html web resource(the resource opens in a new window and not inside the form) which is supposed to retrieve data from the server, display it and allow the user to find links to various documents.

i have a javascript resource attached to an unused form that opens the html web resource on load using window.open, inside the resource is a search box with a button that is supposed to load the necessary data using a script that is on the page itself. however, when i click the button to use the script i get the error

"cr3de_documentSearchWindow:11 Uncaught ReferenceError: Xrm is not defined"

as i understand, xrm loads no problem from a javascript file and i can only use parent.xrm if the xtml web resource is on the same page as the form

any way to access xrm code commands with an html web resource from a seperate window?

i would appreciate help

*This post is locked for comments

I have the same question (0)
  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Etay ,

    I believe you are aware that window.Open is not a supported method in Dynamics CRM , its basically redirecting Outside CRM form. There is no way to use Xrm method except parent.Xrm.

    Use Xrm.Navigation.openWebResource for V9 

    https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-navigation

    Use Xrm.Utility.openWebResource if you are not using V9

    https://msdn.microsoft.com/sl-si/library/jj602956(v=crm.7).aspx

    Use the GetGlobalContext function returns the same context object found in the Xrm.Page.context.

    https://msdn.microsoft.com/en-us/library/gg328541.aspx

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Try to use something like

    window.opener.Xrm to reference Xrm object of calling window.

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    If window.opener.Xrm doesn't work then try parent.window.Xrm.

    Basically you need to find the hierarchy/ path which related the CRM page to the popup.

    Hope this helps.

  • Suggested answer
    santhoshh Profile Picture
    85 on at

    You can referance the Clientglobalcontext in the HTML if Parent.xrm not working.

  • Suggested answer
    Temmy Wahyu Raharjo Profile Picture
    2,916 on at

    Usually I will put this code to scan the correct frame:

    function getXrmFrame() {

               for (var i = 0; i <= parent.frames.length; i++) {

                   var frame = parent.frames[i];

                   if (frame.Xrm && frame.Xrm.Page && frame.Xrm.Page.data && frame.Xrm.Page.data.entity) {

                       return frame;

                   }

               }

               return null;

           }

    var frame = getXrmFrame();

    var Xrm = frame.Xrm;

  • Suggested answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at

    For embedded webresource within entity form use parent.Xrm.Page

    For popup windows, use window.opener.Xrm.Page

    stackoverflow.com/.../7920473

  • Community Member Profile Picture
    on at

    after a few tries, this succeeded. thanks

  • Suggested answer
    shameervv Profile Picture
    10 on at

    It worked

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