{Zero code development}Clone CRM record with Dynamics CRM

Lets take example of Clone Contact.

First we need to create n:1 relationship on Contact record:


Then we need to configure mappings:


Now let us put this field on the form navigation and lookup on Contact form:


Once you click Add New on Cloned contacts:


You see, all fields are copied which were configured. Fill and save:


Notice that source contact record is traceable through lookup(above the map). Happy cloning and hope it helps!

{WorkAround} Trying to import solution error: “This process cannot be activated or deactivated by someone who is not the owner” in Dynamics CRM 2011/2013

We faced the issue during import of solution to new organisation containing 100+ processes. Microsoft suggests to assign all workflows to the user who is going to import the solution. Refer: http://support.microsoft.com/kb/2626779/en-gb

We did not want to manually go and assign all this stuff to the new user. Hence, execute following server side code to achieve the same on target organisation:


WhoAmIRequest request = new WhoAmIRequest();

WhoAmIResponse response = (WhoAmIResponse)service.Execute(request);

QueryExpression query = new QueryExpression("workflow");

query.Criteria.Conditions.Add(new ConditionExpression("statecode",ConditionOperator.Equal,0));

EntityCollection processCollection = service.RetrieveMultiple(query);

foreach(Entity process in processCollection.Entities)


AssignRequest assign = new AssignRequest


//systemuser; i.e., User to whome you are assigning the entity to

Assignee = new EntityReference("systemuser", response.UserId),

//Current record which you are assigning to the user

Target = new EntityReference("workflow", process.Id)


// Execute the Request



The solution will start exporting after this without an error. Hope it helps!

Note:- You need to be System Administrator to be running this code.

Aggregate FetchXml Queries for Dynamics CRM 2011/2013

Recently needed to figure out ways to find sum of various child entity attribute under a parent entity and came across the following way in FetchXml using which can avoid looping through all child entity collection to do various operations such as:

  • sum
  • avg
  • min
  • max
  • count(*)
  • count(attribute name)

Sample FetchXml for sum:

"<fetch distinct='false' mapping='logical' aggregate='true'> <entity name='entity name'> <attribute name='attribute name' aggregate='sum' alias='alias name'/> </entity> </fetch>"

Result xml will be as follows:

"<resultset morerecords="0"'> 
      <alias>aggregate value</alias>

Hope it helps!