Friday 15 September 2017

{know-how} D365 CRM - Get optionset label from Stringmap using FetchXML - c#,JS, SSRS



Hello All,

Good to be back with another know how post. Lets go through a simple way to retrieve a MSCRM optionset label using fetchxml that can be used with C#/JS/SSRS.

Usual way to retrieve an optionset value in c# or JS is by using RetrieveAttributeRequest and refer this blog for the same.

RetrieveAttributeRequest - Option set label retrieval

This time, wanted to stick with old school SQL approach by using stringmap table, so replicated the same logic into fetchxml query and below is the simple fetchxml. This will be handy in SSRS report development to retrieve optionset details.

What is stringmap?
Stringmap is a table in crm which contains all the optionset options and its related details. Will write a quick article soon around stringmap and its fields 😉

Coming back to the topic, below is the fetchxml to get optionset label, hope the fields are self explanatory.

FetchXML

<fetch>
    <entity name="stringmap" >
        <attribute name="value" />
        <filter type="and" >
            <condition attribute="objecttypecodename" operator="eq" value="account" />
            <condition attribute="attributename" operator="eq" value="customertypecode" />
            <condition attribute="attributevalue" operator="eq" value="2" /> 
        </filter>
    </entity>
</fetch>

Result


<result>
    <value>Consultant</value>
</result>

Thursday 7 September 2017

{know-how} MSCRM Actions - Newly created actions not available or missing in plugin registration tool



When we create a new action, sometimes the new action will not be visible in plugin registration tool, this could be due to metadata refresh. Try below options and it should be visible after this.
  1. Deactivate and activate action
  2. Refresh the plugin registration tool
  3. Close and Reopen the plugin registration tool - This option works most of the time

{know-how} MSCRM FetchXML SSRS - Improve performance with No-Lock - FetchXML Nolock



A quick tip around improving CRM data retrieval performance using fetchxml, this is applicable to both RetrieveMultiple  and SSRS performance.

What is no-lock?
Whenever we query CRM using fetchxml,a lock is issued against the table. when we use No-lock the process of issuing lock is skipped. This type of data retrieval is also called as dirty read because there is a chance that you might read the uncommitted data before rollback.

Advantage?

  • Improves SSRS report performance or RetrieveMultiple performance on high transaction oriented tables


Example:

<fetch mapping="logical" no-lock="true" >
    <entity name="account" />
</fetch>