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 365 | Integration, Dataverse...
Suggested Answer

how to handle the deprecation of clientglobalcontext.js.aspx in HTML webresources.

(0) ShareShare
ReportReport
Posted on by 20

Hi, I was wondering if anyone has an option for handling the deprecation of the clientglobalcontext aspx page.

As dialogs are now deprecated and embedding canvas apps in a form or using a PCF control isn't always an option, we've created some custom popups using an HTML webresource and calling them through the new Xrm.Navigation.navigateTo API.

But that leaves a dependency in the webresource on the clientglobalcontext.js.aspx page in order to be able to call Xrm.Utility.getGlobalContext.

Which is now being deprecated as well.

So I'm hoping somebody has figured out a way around this issue, or do we just have to accept the fact that the days of creating our own html controls are now over?

I have the same question (0)
  • Suggested answer
    Ana Almeida Profile Picture
    on at

    Hello Joeri, 

    Can you give me an example of the scenario you want to achieve ?

    For now there is no replacing for ClientGlobalContext.js.aspx, so we have 3 options: 

    1. Use ClientGlobalContext.js.aspx  until it is available

    2. parent.Xrm. (we mentioned way this in docs)

    Earlier: An HTML web resource may interact with the Xrm.Page or Xrm.Utility objects within the form by using parent.Xrm.Page or parent.Xrm.Utility.

    Now: parent.Xrm.* will work if the HTML web resource is loaded in a form container. It won't work for HTML web resources that are stand alone, or referenced from the site map or any other places.

    NOTEparent.Xrm will be removed after the removal of the ClientGlobalContext.js.aspx page; dates yet to be announced.

    3. Use 3rd party library for communication with REST api or stay with XmlHttpRequests

  • Joeri Stroy Profile Picture
    20 on at

    Hi Ana,

    Say I have a button in the ribbon of the Account entity.

    The code behind the button calls Xrm.Navigation.navigateTo() and loads a webresource, lets say for example CopyAccount.html, in a modal.

    At this point I have no way of calling Xrm.Utility.getGlobalContext() inside of the CopyAccount.html without the reference to  'ClientGlobalContext.js.aspx'

    And yes, I can use the REST Api in order to load data into the html file, but even constructing that request needs the url of the environment, which you should get through the getClientUrl() function.

    And even if I were to get the url in some other way, I still wouldn't be able to call any of the other API's in the Xrm.Navigation, Xrm.Utility, ... namespaces like userSettings, openForm(), openAlertDialog(), showProgressIndicator(), .....

    So this makes developing custom html's very convoluted as we would have to recreate all that functionality instead of just being able to call the built in Api's

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

    Hello Joeri,

    I had a chat with Microsoft regarding the same issue and at the moment the only "easy" way is usage of parent.Xrm even it's not recommended.

  • Suggested answer
    Ana Almeida Profile Picture
    on at

    Hello Joeri,

    To explicitly answer your question, you can use both ClientGlobalContext.js.aspx and other API's now.  

    Once the deprecated functionality is removed using both will continue to work in the form but outside of the form only ClientGlobalContext.js.aspx and GetGlobalContext() will work.  

    Please start using ClientGlobalContext.js.aspx and GetGlobalContext() to prepare for deprecated functionality being removed.

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

    Ana,

    I'm sorry but how could you recommend to use something that will stop working in few months? As far as I understood after conversation with product group their main intention is to warn developers to stop using this approach and use alternative. You recommendation looks misleading for me.

  • Joeri Stroy Profile Picture
    20 on at

    Hi Ana,

    I must say I agree with Andrew on this, your answer kind of confuses me more.

    The whole issue I'm having is that it has been announced ClientGlobalContext.js.aspx will be deprecated.

    And now you are suggesting I should start using it?

  • Suggested answer
    Ana Almeida Profile Picture
    on at

    Hello Joeri Stroy,

    It’s important to highlight what deprecated means that “we intend to remove the feature or capability from a future major release of Dynamics 365. The feature or capability will continue to work and is fully supported until it is officially removed.” 
    So, in resume, for now there is no replacing for ClientGlobalContext.js.aspx, so we have 3 options:
    1. Use ClientGlobalContext.js.aspx until it is available

    2. parent.Xrm. (we mentioned way this in docs)

    Earlier: An HTML web resource may interact with the Xrm.Page or Xrm.Utility objects within the form by using parent.Xrm.Page or parent.Xrm.Utility.

    Now: parent.Xrm.* will work if the HTML web resource is loaded in a form container. It won't work for HTML web resources that are stand alone, or referenced from the site map or any other places.

    NOTE: parent.Xrm will be removed after the removal of the ClientGlobalContext.js.aspx page; dates yet to be announced.

    3. Use 3rd party library for communication with REST api or stay with XmlHttpRequests

  • Shaun W Harvey Profile Picture
    242 on at

    Hello,

    The deprecation has now been announced as October 1st, 2022.

    According to the MS Documentation:

    docs.microsoft.com/.../getglobalcontext-clientglobalcontext.js.aspx

    On the SiteMap of our model driven app. We have navigation items that use an HTML Web Resource to redirect to an Azure Hosted Website that works alongside our Model-Driven App.

    In that HTML Web Resource we have to use the clientglobalcontext.js.aspx to get a reference to the Global Context to get the current Dynamics Logged-In User.

    That User ID alongside some configuration information stored in the Dataverse table enables us to create a Custom Redirect URL for that user to the other site.

    With the proposed Deprecation of clientglobalcontext.js.aspx in October 2022.

    docs.microsoft.com/.../getglobalcontext-clientglobalcontext.js.aspx

    I am trying to determine how to implement this functionality going forwards.

    The alternatives suggested:

    1. Power Apps Component Framework - From what I have seem - I don't think you can have a PCF control bound to a SiteMap Navigation item. Unless I am missing something?

    2.  Custom Pages - Again, as far as I can see. Cannot be associated with a SiteMap Navigation item.

    We are calling a stand-alone web resource from the SiteMap here. So, workarounds such parent.Xrm.* will not work as the Web Resource is not hosted on a form.

    Is there an alternative Library available to allow us to retrieve the Global Context in an HTML Web Resource?

    Best Regards,

    Shaun Harvey

  • Shaun W Harvey Profile Picture
    242 on at

    Anyone else still struggling with the removal of this in HTML Web Resources?

  • Joeri Stroy Profile Picture
    20 on at

    To be honest Shaun, I kinda gave up on this one.

    Matt Barbour told me at a conference last year they were working on something, but one year later, still waiting...
    I'm guessing that as long as they haven't ported everything away from the old legacy aspx interface, the clientglobalcontext.js.aspx will keep working just fine.

    I've personally been working around the issue as much as possible using PCF and regular React controls and discouraging our customers from implementing this type of customization altogether.

    Regards

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 365 | Integration, Dataverse, and general topics

#1
iampranjal Profile Picture

iampranjal 41

#2
Martin Dráb Profile Picture

Martin Dráb 38 Most Valuable Professional

#3
Satyam Prakash Profile Picture

Satyam Prakash 35

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans