Some CRM 2011 JavaScript

//Hide Section in

Xrm.Page.ui.tabs.get(“Name of the tab”).sections.get(“Name of the section”).setVisible(true);

Xrm.Page.ui.tabs.get(“Name of the tab”).sections.get(“Name of the section”).setVisible(False);

//Force Submit method has changed to

Xrm.Page.getAttribute(“Field Name”).setSubmitMode(“always”);

//Get Selected Picklist value

var _Value = Xrm.Page.getAttribute(“Name of Picklist”).getSelectedOption().text;

//Get Entity Attributes based on ID

var context;

var serverUrl;

var ODataPath;

function Getinfo() {

    context = Xrm.Page.context;

    serverUrl = context.getServerUrl();

    ODataPath = serverUrl + “/XRMServices/2011/OrganizationData.svc”;


function GetID() {

    var ID = Xrm.Page.getAttribute(“Nameof ID field”).getValue()[0].id;



function RetrieveAccountRecord(Id) {

    var RetrieveAccountReq = new XMLHttpRequest();“GET”, ODataPath + “/AccountSet(guid'” + Id + “‘)”, true); //I am fetch account data

    RetrieveAccountReq.setRequestHeader(“Accept”, “application/json”);

    RetrieveAccountReq.setRequestHeader(“Content-Type”, “application/json; charset=utf-8”);

    RetrieveAccountReq.onreadystatechange = function() {





function RetrieveAccountReqCallBack(RetrieveAccountReq) {

    if (RetrieveAccountReq.readyState == 4 /* complete */) {

        if (RetrieveAccountReq.status == 200) {

            var RetrievedAccount = this.parent.JSON.parse(RetrieveAccountReq.responseText).d;






        else {


            alert(“Error in Fetch Account data”);

        }    }}

 Reference : Microsoft Dynamics CRM 2011 SDK

Enjoy !!!



Filed under MS CRM 2011

5 responses to “Some CRM 2011 JavaScript

  1. j0ngleur

    very nice!

    just some small errors: “retrievedAccount” is sometimes beginning with lower case but defined as “RetrievedAccount” (the same goes for “retrieveAccountReq”)

  2. Thanks for sharing such a good idea, paragraph is fastidious,
    thats why i have read it fully

  3. Helpful info. Lucky me I discovered your site unintentionally, and I’m shocked why this twist of fate didn’t happened earlier!
    I bookmarked it.

  4. Greetings! Very helpful advice in this particular article! It’s the little changes that produce the largest changes. Many thanks for sharing!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s