Michael Philip's Blog

Writing about MS Tech with strong focus on Azure & CRM


Leave a comment

How To : Disable Left Navigation Menu in CRM 2011

function DisableFormNavigationMenu(menuLabel) {

var navItems = Xrm.Page.ui.navigation.items.get();

for (var i in navItems) {

var navItem = navItems[i];

var itemLabel = navItem.getLabel();

if (itemLabel == menuLabel) {

var navItemId = navItem.getId();

var navElement = document.getElementById(navItemId);

if (navElement) {

navElement.disabled = true;

navElement.onclick = null;

}
break;
}
}
}

Advertisements


Leave a comment

How To : Get Business Unit & Organization Id’s of a Calling User in Microsoft Dynamics CRM 2011 in .NET With WhoAmIRequest

The following code will show you how to get Business Unit & Organization Id’s of a Calling User in Microsoft Dynamics CRM 2011 in .NET With “WhoAmIRequest.”

Code:

WhoAmIRequest Request = new WhoAmIRequest();
WhoAmIResponse Response= (WhoAmIResponse)_serviceProxy.Execute(Request);

Image


Leave a comment

How To : Delete a Record in Microsoft Dynamics CRM 2011 Using .Net

The following code will show you who to delete a record of any entity type using .Net.

Code:

// Create Request
DeleteRequest Request = new DeleteRequest();

// Set Target (record you want to delete)
Request.Target = new EntityReference(“account”, new Guid(“72876387-9E5C-E111-B314-1CC1DEF1353B”));

// Execute Request
DeleteResponse Response = (DeleteResponse)_serviceProxy.Execute(Request);

Note: you can find A way to initialize a service proxy at the following link
https://crmprof.wordpress.com/2013/03/13/creating-organization-service-proxy-in-microsoft-dynamics-crm-2011/

 


Leave a comment

How To : Check if an Entity can Participate in Many-To-Many Relationships in Microsoft Dynamics CRM 2011 Using VB.NET

The following code shows how you can check if an Entity can be the Primary Entity in a Many-To-Many Relationship or not.

Code:

//Create The Request
CanManyToManyRequest Request = new CanManyToManyRequest();

//Set Entity Name
Request.EntityName = “account”;

//Execute 
CanManyToManyResponse Response = (CanManyToManyResponse)_serviceProxy.Execute(Request);

//Get The Result
var result = Response.CanManyToMany;

 


Leave a comment

How To : Check if an Entity can be the Primary Entity in a One-To-Many Relationship in Microsoft Dynamics CRM 2011 Using .NET

The following code shows how you can check if an Entity can be the Primary Entity in a One-To-Many Relationship or not.

Code:

 

  //Create Request
  CanBeReferencedRequest Request = new CanBeReferencedRequest();

 //Set Entity Name
Request.EntityName = “account”;

 //Get Response
CanBeReferencedResponse Response = (CanBeReferencedResponse)_serviceProxy.Execute(Request);

 //Get Result
var result = Response.CanBeReferenced;


Leave a comment

Install Sample Data in Microsoft Dynamics CRM 2011 Using .NET With InstallSampleDataRequest

This following code  shows how to install the sample data that comes with Microsoft Dynamics CRM 2011 with InstallSampleDataRequest Using .Net

Code:

 

InstallSampleDataRequest req = new InstallSampleDataRequest();

InstallSampleDataResponse resp = (InstallSampleDataResponse)_serviceproxy.Execute(req);

 


Leave a comment

How TO :Get Text Value of an OptionSetValue Using LINQ in Microsoft Dynamics CRM 2011

i have been always trying to get the label of an option set value by the way described in the following link https://crmprof.wordpress.com/2013/05/18/how-to-get-the-label-value-for-an-optionset-using-retrieveattribute-request-in-microsoft-dynamis-crm-2011/,  which uses RetrieveAttributeRequest and passing the value which we want to get its label.

CRM 2011 Provides a new way instead of the one described at the link which is using LINQ To CRM Queries.

The basics are as follows. 

1. Use CrmSvcUtil.exe (comes with the SDK) to get a context that you can use with the CRM LINQ provider.

2. Use LINQ to pull the entity attribute FormattedValues for a specific attribute of type OptionSetValue.  The example below is pulling based on a specific entity ID so it pulls the specific text value of the optionset in this instance.

var strstringvalue = (from ca in context.CreateQuery<CampaignActivity>() where ca.ActivityId == campaignResponse.new_CampaignActivityId.Id select ca.FormattedValues[“new_campaignactivitytype”]);