Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum

Xrm.Page deprecation and a NEW WAY of getting the execution context from an HTML Web Resource!

Posted on by 77

On this page:

https://docs.microsoft.com/en-us/dynamics365/get-started/whats-new/customer-engagement/important-changes-coming

it explains just over half way down the page that Xrm.Page is deprecated.

Interestingly, it notes the following:

Although Xrm.Page is deprecated, parent.Xrm.Page will continue to work in case of HTML web resources embedded in forms as this is the only way to access the form context from the HTML web resource.

Note my underline above.  I'm in the midst of an upgrade project from Dynamics v8 to v9 and need to get the form context for an HTML web resource.  I was going to use parent.Xrm.Page but just before I did that I started to play about in dev tools for IE.  It was here that I noticed I could do:

window.parent.constructExecutionContext().getFormContext();

I got the form context!  Testing this out, the code worked perfectly.

To me this is a big deal but when I search online for any documentation or posts about constructExecutionContext() I get zero results.

Have we a bonafide way of obtaining the context and Microsoft have just forgot to mention it?  Should Microsoft update the guidance in the web page above?

I'd like to verify that this is supported.  Can we get someone from Microsoft to confirm?

EDIT: This post is not about the currently documented way to get the form context by using executionContext.getFormContext() but rather getting the form context from an HTML web resource using the, from what I can so far tell, the undocumented constructExecutionContext() method.

  • Antony Ellis Profile Picture
    Antony Ellis 65 on at
    RE: Xrm.Page deprecation and a NEW WAY of getting the execution context from an HTML Web Resource!

    I completely agree here with the thread author he was not actively looking for unsupported methods or trying to challenge it (the opposite). The Microsoft documentation is Contradicting, bad enough they have deprecated *the fundamental* client object model which is used by countless implementations (Xrm.Page) BUT then go on to say use a deprecated model in web resources. Annoying, why not fix that and be consistent on new approach whilst telling people something is deprecated.

  • CVO Profile Picture
    CVO 77 on at
    RE: Xrm.Page deprecation and a NEW WAY of getting the execution context from an HTML Web Resource!

    I agree completely, use documented methods.  I think the big thing here, for me anyway, is that the documented method is to use Xrm.Page, which Microsoft say is deprecated!

    So we are told we should not use deprecated methods, but then told to do so in this instance.  We know Xrm.Page will be removed at some point since it is deprecated, so this will guarantee failure in a future update.  I'm going to use the undocumented method.  If it breaks in a future update then I am no worse off, since Xrm.Page, by its very nature of now being deprecated, will break in a future update anyway.

  • Suggested answer
    Arun Vinoth Profile Picture
    Arun Vinoth 11,613 on at
    RE: Xrm.Page deprecation and a NEW WAY of getting the execution context from an HTML Web Resource!

    There is no point in ignoring MS documented recommendation method and asking about undocumented (intended for internal usage) method to include in documentation & verified by MS to use by community.

    We did upgrade from v8.2 to v9, remediated all code per documentation, nothing breaks.

    If you use unsupported thing that’s upon your decision, if it breaks in future updates MS don’t have any obligation to fix/support it for you.

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Xrm.Page deprecation and a NEW WAY of getting the execution context from an HTML Web Resource!

    Hi CVO,

    You may find several other methods which are not document but works perfectly fine. So I am thinking this is one of the those method. I would personally always prefer to go for the documented way as with this, I am sure that this will not be removed all of a sudden. Even if there are any changes to the suggested documented way, there will be guidelines from Microsoft on how to transition from old method to new method.  

    It is also possible that Microsoft will introduce this method constructExecutionContext() in the future release but who knows if they change the name or something else which may break your code.

    So in short, if it is documented, use it instead of using any undocumented/ unsupported method.

    Hope this helps.

  • CVO Profile Picture
    CVO 77 on at
    RE: Xrm.Page deprecation and a NEW WAY of getting the execution context from an HTML Web Resource!

    Hi Goutam,

    From what I see, your post is about using executionContext.getFormContext() in the form where executionContext is available.

    My post above refers to obtaining the exucutionContext outside of the form in an HTML web resource and specifically the method "constructExecutionContext" which from what I can see is not currently documented anywhere.

    I will edit my original post to say explicitly this is not about executionContext.getFormContext.

    Regards,

    Chris

  • gdas Profile Picture
    gdas 50,085 on at
    RE: Xrm.Page deprecation and a new of getting the execution context from an HTML Web Resource

    Hello ,

    Please check my comments in below thread -

    community.dynamics.com/.../275459

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans