CRM 2013

Get Status Text for a Value in CRM

Posted on

public static string GetStatusTextForValue(IOrganizationService service, string entityName, string attributeName, int selectedValue)
{
var retrieveAttributeRequest = new RetrieveAttributeRequest
{
EntityLogicalName = entityName,
LogicalName = attributeName,
RetrieveAsIfPublished = true
};
string statusCodeLabel = “”;
try
{

RetrieveAttributeResponse attributeResponse =
(RetrieveAttributeResponse)service.Execute(retrieveAttributeRequest);
AttributeMetadata attrMetadata = attributeResponse.AttributeMetadata;

StatusAttributeMetadata statusAttrMetadata = (StatusAttributeMetadata)attrMetadata;

foreach (StatusOptionMetadata statusMeta in statusAttrMetadata.OptionSet.Options)
{
if (statusMeta.Value == selectedValue)
{
statusCodeLabel = statusMeta.Label.UserLocalizedLabel.Label;
break;
}
}
}
catch (Exception ex)
{
var retrieveAttributeResponse =
(RetrieveAttributeResponse)service.Execute(retrieveAttributeRequest);
var retrievedPicklistAttributeMetadata =
(PicklistAttributeMetadata)retrieveAttributeResponse.AttributeMetadata;
OptionMetadata[] optionList = retrievedPicklistAttributeMetadata.OptionSet.Options.ToArray();
foreach (OptionMetadata oMD in optionList)
{
if (oMD.Value == selectedValue)
{
statusCodeLabel = oMD.Label.LocalizedLabels[0].Label;
break;
}
}
}
return statusCodeLabel;
}

Advertisements

Trigger plugin for N:N relationships in Dynamics CRM

Image Posted on

Yesterday I was working on a requirement to trigger a plugin for N:N relationship. The idea is as soon as a record on N:N subgrid is added, trigger the plugin. Follow steps below for this –

1. Create a PreUpdate plugin on the entity

2. Check Message Name in from the PluginExecutionContext. Use Associate if checking for addition of a record in N:N or Disassociate for deletion of record in N:N

3. Validate Context depth is 1, this is to avoid recursive / infinite loops

4. Use “Relationship” input parameter to get current entity

5. Use Relation Entity schema name to get related entity record. This can be found by opening the respective N:N relationship.

6. Ensure the Plugin is registered with following values –

3

 

 

Code snippet below –

1

Hope it helps..

CRM 2013 to CRM 2015 upgrade

Posted on

Hi,

I have just downloaded the preview bits for CRM 2015. I have a CRM 2013 On-Premise instance with Service Pack 1 which I am trying to upgrade to CRM 2015. I think the prerequisites mentioned on the official video and website are incorrect. It seems the minimum requirement is CRM 2013 SP1 Rollup 1 i.e. build version 6.1.1.132
Cheers,
Mayank

Hosting CRM 2013 on Azure

Posted on

If you are planning to host CRM 2013 on Azure please follow steps below –

1. Create a new VM on Azure

2. Enable AD on the VM by running dcpromo from command prompt

3. Install SQL Server

4. Install Dynamics CRM 2013

Please note, this is not a supported infrastructure and CRM online or CRM hosting OneNet are the best available options.

CRM 2013 Service Pack 1 Roll up 1

Posted on

Microsoft is soon releasing Roll up 1 for CRM 2013 Service Pack 1. Watch this space for updates and release date of the package.

CRM 2013 IFD not working with Windows Server 2012 R2

Posted on

Hi,

Please be advised that although Server 2012 R2 is mentioned as supported infrastructure for CRM 2013. But, if you are planning to install ADFS on the server, please refrain from doing so, as it still doesn’t work very well with CRM 2013