Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

GetGlobalContext Function

[Applies to: Microsoft Dynamics CRM 2011]

Use the GetGlobalContext function when programming with web resources to gain access to context information.

The GetGlobalContext function returns the same context object found in the Xrm.Page.context. When programming in a form, use Xrm.Page.context.

When you need context information outside a form, include a reference to the ClientGlobalContext.js.aspx page in an HTML web resource.

You can use the GetGlobalContext function when you include a reference to the ClientGlobalContext.js.aspx page located at the root of the web resources directory.

If you are not using backslash characters in web resource names to simulate a folder structure, you can include this script in your page using this script element: <script type="text/javascript" src="ClientGlobalContext.js.aspx"></script>

If you are using backslash characters in web resource names to simulate a directory structure, you must reflect this in your script element. The following example is for an HTML web resource named ‘sdk_/Contoso.htm’ and a JScript web resource named ‘sdk_/Scripts/ContosoScript.js’.

    <title>HTML Web Resource</title>
    <script src="../ClientGlobalContext.js.aspx" type="text/javascript" ></script>
    <script src="Scripts/jquery1.4.1.min.js" type="text/javascript"></script>
    <script src="Scripts/ContosoScript.js" type="text/javascript"></script>
    <link href="Styles/ContosoStyles.css" rel="stylesheet" type="text/css" />

Using a relative path including the root WebResources folder, for example, /WebResources/ClientGlobalContext.js.aspx, is not recommended because it can cause the page to lose organization context in a multi-tenant environment.

The ClientGlobalContext.js.aspx page will include some global event handlers. These event handlers will cancel the onselectstart, contextmenu, and ondragstart events.

Microsoft Dynamics CRM 2011
Send comments about this topic to Microsoft.
© 2013 Microsoft Corporation. All rights reserved.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.