Monday, August 8, 2011

GetGlobalContext on MS CRM 2011

GetGlobalContext is a very good feature(function) given by MS in ms 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 /webresources/ClientGlobalContext.js.aspx page in an HTML Web resource.

The context provides access to the following functions:

getAuthenticationHeader: Returns the encoded SOAP header that you need to use Microsoft Dynamics CRM 4.0 Web service calls using Jscript.

getOrgLcid: Returns the LCID value that represents the Microsoft Dynamics CRM Language Pack that is the base language for the organization.

getOrgUniqueName: Returns the unique text value of the organization’s name.

getQueryStringParameters: Returns an array of key value pairs representing the query string arguments that were passed to the page.

getServerUrl: Returns the base server URL. When a user is working offline with Microsoft Dynamics CRM for Microsoft Office Outlook, the URL is to the local Microsoft Dynamics CRM Web services.

getUserId: Returns the GUID value of the SystemUser.id for the current user.

getUserLcid: Returns the LCID value that represents the Microsoft Dynamics CRM Language Pack that is the user selected as their preferred language.

getUserRoles: Returns an array of strings that represent the GUID values of each security role that the user is associated with.


Sample:
<script src="../ClientGlobalContext.js.aspx">
function getServerPath(){
var context = GetGlobalContext();
var serverUrl = context.getServerUrl();
}
</script>


No comments:

Post a Comment