RAJEEV KUMAR, Azure Architect, Azure Data Engineer, AZURE Developer, Prince2®, SAFe®, CSM®, ITIL® (Linkedin: www.linkedin.com/pub/rajeev-kumar/13/459/663)
Tuesday, February 16, 2016
MS Dynamics CRM 2011/2013/2015: Reasons to Register Plugins in Database Instead of...
MS Dynamics CRM 2011/2013/2015: Reasons to Register Plugins in Database Instead of...: I decided to post this article since I am hearing quite often about developers using Disk and GAC for registering the custom plugin as...
Reasons to Register Plugins in Database Instead of Disk/GAC
I decided to post this article since I am hearing quite often about developers using Disk and GAC for registering the custom plugin assemblies in CRM 2011/2013/2015/2016. I have also heard claims such as “you must register on disk in order to debug” or “it is easier to update the assembly version when they are stored on disk” which I will do my best to disprove.
1. Only database assemblies can be packaged in solutions
Solutions are the future of CRM and Microsoft is not supporting packaging disk/GAC assemblies in solutions. Such statement almost suggests that GAC and disk are legacy registration modes, and moving forward only database should be used. Take advantage of being able to export, transport and import your plugin in a solution by registering it on database.
2. Zero service interruption to update a database assembly
If you register your assembly on disk or GAC and you would like to update it, you might be aware that even after the file is overwritten, the changes will not take effect until you do an “iisreset” which will cause down-time to your organization. Additionally, you must consider whether the plugin is asynchronous in which case you must also restart the CRM Asynchronous Processing service. Besides the down-time, there are also a number of manual steps to restart the services that you would probably want to avoid. If you register on database, all you need to do is click on “update” using the Plugin Registration Tool and update the assembly content.
This is indeed just as fast (if not faster) than drag-drop-replace but you won’t need to restart the services because the new assembly will take effect immediately after the update! The reason why you don’t need to restart the services is that the assembly loading routine from the bytes works different in .Net. When loading from GAC or disk, the assembly is loaded in the AppDomain as is never loaded again until the AppDomain or process is restarted. Note that if you plan to debug the assembly, you still need to copy the symbols to disk (symbols cannot go in database) and you can debug as usual.
3. Simplified organization backup / import.
If your plugins are registered on disk/GAC then backing up the organization database will not be enough. You will need to also backup all the custom assemblies you might have in the GAC or in disk. When you import the organization then you must also remember to copy those dll’s back into the new server(s). However, if you use database assemblies you only need the database backup and forget about tracking down these custom assemblies in order to restore your organization.
4. Disk assemblies will not support multiple versions
In CRM 2011 there is support for assembly versioning so you can have multiple versions of a given assembly coexisting in the system. For example, the workflow designer lets you select which version of a particular assembly for a custom workflow activity you would like to use:
Because both versions of the assemblies would have the same file name then you cannot register them simultaneously on disk.
5. All assemblies consolidated into a single place
With database assemblies another good thing is that they are all stored in a single place: the database. You don’t need to worry about deploying dll’s to file and GAC in multiple servers. If your CRM deployment is spread out in different server roles for load balancing, then you don’t have to worry about which roles will need your assemblies and on what servers you must deploy which assemblies. It can be really cumbersome with disk/GAC assemblies as you can easily lose track for example of which plugins run asynchronous vs. synchronous so they must be deployed to the web and async servers respectively.
6. Sandbox and CRM Online only support database assemblies
If you have your assemblies registered on database, you could include them in a solution. Therefore, you can easily migrate to CRM Online by exporting/importing the solution and you can mark your assemblies as sandboxed. You would not be able to sandbox your assemblies for disk/GAC and you would not be able to package them to migrate to CRM Online.
When should I Use Disk mode to register Plugin/Workflow ?????????
only put a plugin on disk if you want to remote debug it because you then need to put the dll and the pdb file on the server.
Tuesday, February 9, 2016
Calculated Fields in CRM 2015
- Calculated fields are always performed in real time
- Calculated fields are always read only
- Calculated field values are not stored in the MS CRM DB. Instead, a MS SQL function is called in order to perform the calculation and then present the result in a form, view or chart
- Calculated fields can use data from the same entity or any other related entity. They can only span a maximum of 2 entities
- Calculated fields cannot be used to trigger events such a workflow or plugins
- Calculated fields can be used within another calculated field, however you can only have a maximum of 5 chained fields to help mitigate against any potential performance issues
- If the calculate field results is over 4000 characters, the data will be truncated with no indication made to the user.
- Calculated fields will not work in offline mode
- Circular references are prohibited so therefore you cannot reference the same calculated field within the calculation (i.e. within the action section of the calculated field properties)
- Saved queries, charts and visualizations can only have a maximum of 10 calculated fields
- You can only sort a view if the calculate field uses fields from within the same entity. If the calculated field used fields from a parental entity, you will be unable to sort on the calculated field.
Monday, February 8, 2016
Concatenate Two Fields in Microsoft CRM 2015
This is a combination of the account name and the phone number our CRM Administrator decides this is a perfect opportunity to use the calculated attributes function found in CRM 2015.


Notice a comma separates each of the attributes or literal in the expression.
Our example the expression would look as follows:




- She therefore will start off by opening a solution set and create a new attribute called ACCOUNT ID to retain the calculated information.

- She defines the attribute as a single line of text.
- The field type is defined as calculated.
- The Format as Text
- Click on Save
- The click on the Edit button to the left of the field type

- This will open the calculated field dialog box
- Since this is straight forward implementation there is no reason to configure the condition, (in this case all records when created will require a unique ID).
- Using the Concat() function in CRM Action section, she can define the formula. Please note member attributes require a (,) comma to separate them within the function. If you are going to add a literal then it must be defined with double(“) quotes.
Notice a comma separates each of the attributes or literal in the expression.
Our example the expression would look as follows:

- Click on the check icon in the lower right corner of the expression to check for accuracy, (if the function is incorrect the application will throw an error message).
- Click on Save and close.

- Save the attribute and close.
- Place the attribute on the form
- Click on save
- Click on publish

- Close the form.

Friday, February 5, 2016
Closing an opportunity Programmatically
Entity opptyCloseObj = new Entity("opportunityclose");
opptyCloseObj.Attributes.Add("opportunityid", new EntityReference("opportunity", OpptyID)); opptyCloseObj.Attributes.Add("actualend", DateTime.Now);
opptyCloseObj.Attributes.Add("actualrevenue", ActualopptyAmount);
var lostOpportunity = new LoseOpportunityRequest
{
OpportunityClose = opptyCloseObj,
Status = new OptionSetValue(MIGRATED_STATUS_CODE) // Expired
};
ServiceObj.Execute(lostOpportunity);
Thursday, February 4, 2016
Limitations with FetchXML
1.
RIGHT
OUTER JOIN is not supported.
2.
You can't compare two fields
directly. For instance, you won't be able to find an equivalent query for the
following SQL script:
|
SELECT * FROM account
WHERE telephone1
<> telephone2
|
|
SELECT a.*
FRM entity1 a
INNER JOIN entity2
b ON a.entity1id = b.entity1id
WHERE a.name = '123' OR b.name = '123'
|
3.
The right side of the comparison has
to be a constant value.
4.
You can't have OR condition across entities. For instance, the following
SQL query is not supported by FetchXML.
5.
If you ever have to do so, you would
have to break the query into two, and get the results by issuing two queries
against CRM server separately, then merge the result set.
6.
You can't use SQL functions in
FetchXML query. CRM has support for some built-in functions, but any additional
SQL functions are not supported.
7.
No support of UNIONs (Thanks to Dirk
Fabricius for his contribution by commenting below).
8.
There is no support of a CASE / WHEN structure.
9.
When you issue a FetchXML query, the
maximum number of records you get back from CRM server is 5,000 each time. If
you want to get more records from CRM server, you would have to use paging cookie.
10.
You can't have more than 10 linked
entities in a FetchXML query. It is possible to overcome this limit by creating
or updating a QueryLinkEntityLimit setting,
however this is generally not recommended. If you ever run into this situation,
you would definitely want to re-visit your CRM data model or re-engineer your
query.
11.
When you perform an aggregation, the
maximum number that will participate in the aggregation will be 50,000 records.
For instance, if you do a COUNT aggregation, the maximum value you can get back
from CRM is 50,000 even though that you might have more records in the system.
This is a by-design behavior which is for performance reason. This can be
overcome by updating "AggregateQueryRecordLimit" setting, however it is generally not recommended.
12.
There is no way to use subquery.
Friday, January 29, 2016
Subscribe to:
Posts (Atom)
Get files of last hour in Azure Data Factory
Case I have a Data Factory pipeline that should run each hour and collect all new files added to the data lake since the last run. What is...

-
I find that using workflow id might be problematic across deployment, so I wrote a function to retrieve workflow’s guid given the workflow...
-
Microsoft Dynamics CRM supports two types of parameters for a workflow activity. Input Parameters Output Parameters Input Paramete...
-
Case I have a Data Factory pipeline that should run each hour and collect all new files added to the data lake since the last run. What is...