Archive for August, 2014

Execute Custom Action using Late Binding – CRM 2013

Custom Actions provide the ability to write reusable modules of logic that can be triggered through client-side or server-side code.

Custom actions run synchronously and can take in parameters as well as return values.

In this article I will walk you through creation of a Custom Action with Input Parameters and execute the same using SDK call.

My Custom Action created on ‘Account’ entity and will do below actions

  • Takes a Input Parameter of type ‘Entity Reference’ to User, to set Owner of the Task to Accounts Owner
  • Create a new Task
Custom Action

Custom Action

  • Sets Owner of Task to Account’s Owner
Custom Action - Create Task

Custom Action – Create Task

  • Make sure you publish the ‘Custom Action’

Execute Custom Action :

  • We can execute Custom Action using Early or Late binding approach
  • For early binding we need to generate wrapper using exe tool by including ‘generateActions’ tag in console command.

CrmSvcUtil.exe /url:http://<serverName>/<organizationName>/XRMServices/2011/Organization.svc /out:<outputFilename>.cs /username:<username> /password:<password> /domain:<domainName> /namespace:<outputNamespace> /serviceContextName:<serviceContextName> /generateActions

  • Below is the code to execute using Late Bound technique

OrganizationRequest executeCreateTaskOnAccount = new OrganizationRequest(“new_CreateTaskOnAccount”);
// Set Account Owner EntityReference Input Parameter
Guid accountOwnerId={Account Owner GUID};
var accountOwner = new EntityReference(“systemuser”, accountOwnerId);
executeCreateTaskOnAccount.Parameters.Add(new KeyValuePair<string, object>(“AccountOwner”, accountOwner));

Few points :

  • Custom actions can be triggered using JScript and SDK calls
  • We cannot execute Custom Actions from a workflow
  • However you can create a Custom Workflow with ‘Custom Action’ execution logic and call from a Workflow
  • A security privilege named Activate Real-time Processes (prvActivateSynchronousWorkflow) is required to activate an action’s real-time workflow so that it can be executed


Categories: CRM 2013 Tags: , ,

Teams vs Access Teams vs Access Team Templates – CRM 2013

August 24, 2014 1 comment

As we know “Access Teams” are one of the new feature in CRM 2013.

Let’s see how this is different from Legacy Owner Team and finally how is it different from “Access Team Templates”.

Consider a scenario, Where we need to change the Accessibility of ‘Account’ records frequently

  • I have 3 Accounts in my system
  • Account 1 can be (Read/Write/Delete) only by User 1,User 2, User 3
  • Account 2 can be (Read/Write/Delete) only by User 4,User 5, User 6
  • Account 3 can be (Read/Write/Delete) only by User 6,User 7, User 8

We can achieve above requirement by below approaches.

Approach 1:

  • Create 3 teams with a Security role having Read, Write, Delete Privileges to Account
    • Team 1 (User 1,2,3), Team 2 (User 4,5,6), Team 3 (User 6,7,8)
  • Change the Ownership of Accounts to
    • Owner of Account 1 = Team 1; Account 2=Team 2 and Account 3 =Team 3
  • Or Share the Account records to Teams instead of Ownership.

Drawbacks of Approach 1 :

  • Sharing records to a Team with the same sets of users, with the same rights is a performance over head.
  • Add/remove users from team require CRM to reset the Cache and must be recreated by querying the SQL next time the user tries to perform any action.
  • We cannot show who all are working on the Account on the form (Only was is to open Share window and go to the Team to see the list of Users).

Approach 2:

  • Using Access Teams; Let’s see how it is different from old Team approach.

Access Teams :

  • In simple terms, Access Team is a kind of Team with no security role (i.e., No specific privileges at that time of Team creation)
  • Privileges are determined when you align the Access Team to a record via Sharing.
Share Access Team

Share Access Team

Access Team Templates :

  • We define a set of privileges while creating ‘Team Template’
Access Team Template

Access Team Template

  • Add a “Access Team” sub grid on the form. (How to create and add as Sub grid)
  • Add different Users to the “Access Team Sub Grid” for different Accounts. (i.e., User 1,2,3 for Account 1;User 4,5,6 for Account 2…).
Access Team Sub Grid On Account Form

Access Team Sub Grid On Account Form

Access Team vs Access Team Templates :

  • Underlying principle for both Access Team and Access Team Templates are same that No associate security role.
  • With ‘Access Team Templates’ privileges are pre-determined, but the people are not. With Access Teams, the people are pre-determined, but the privileges are not.

Team vs Access Teams :

  • Teams associated with a Security Role but not the case with Access Teams.
  • Records cannot be owned by Access Teams.
Access Teams Are Not For Ownersip

Access Teams Are Not For Ownership

  • You can create views or reports on Access Team Members but not with Teams.

Few more points :

  • Users have to have to Share privilege to add Users to “Access Team” sub grid.
  • We can have more than 1 Access Team sub grid on a form
  • The default number of access teams templates for each entity is two
  • The number of access team templates you can have for each entity is controlled by the MaxAutoCreatedAccessTeamsPerEntity deployment setting.
  • MaxEntitiesEnabledForAutoCreatedAccessTeams deployment setting has a default value of 5. This controls the number of entities it’s possible to enable for auto-created access teams.
  • We can change the MaxEntitiesEnabledForAutoCreatedAccessTeams , MaxAutoCreatedAccessTeamsPerEntity only on Premise installations and cannot edit them for Online.
  • To delete a Access Team Template, we need to remove all the associated ‘Access Team Template’ sub grids before.
  • A system generated Access Team isn’t created for each record until you add a user to the sub grid on the entity.
  • We can covert normal Teams to Access Teams.


CRM Optionset Enum generation tool

I recently used CrmSvcUtilGenerateOptionSetEnums tool from CodePlex to generate Enum for my Optionsets.

This tool is helpful, if you have to refer Option set values in your Plug-ins or Custom code.

We just need to run the below command on Console to generate output file

CrmSvcUtil.exe /codecustomization:”GenerateOptionSetEnums.CodeCustomizationService, GenerateOptionSetEnums” /codewriterfilter:”GenerateOptionSetEnums.FilteringService, GenerateOptionSetEnums” /url:http://Server/Organization/XRMServices/2011/Organization.svc /out:Attributes.cs /basetypes:Microsoft.Xrm.Client.CrmEntity

Output file contain generated enum’s per entity as below

Output file

Output file

Target CRM Version in Solutions – CRM 2013 Spring feature

With Spring update we got a new option “Target CRM Version” while exporting the solution.

Available options are 6.1 (default) and 6.0.

Target Solution CRM Version

Target Solution CRM Version

If you choose 6.0, any new capabilities of version 6.1 will not be included in the exported solution and any organizations still using version 6.0 will be able to install the solution.

All the removed or modified components will be listed out in a dialog.

Removed or Modified components

Removed or Modified components

Note – “Target CRM Version” option is unavailable if you export Default solution.

IntroducedVersion Property

  • In CRM 2013, solution component has an IntroducedVersion property.
  • This value captures the current product version number of the solution that the solution component was associated with when it was created.

Refer these links for more info


Categories: CRM 2013 Tags: ,

Missing ‘Connect to Dynamics CRM Server’ from visual studio solution

August 6, 2014 2 comments

I recently created a new Visual studio solution using Dynamics CRM 2013 Template.

Dynamics CRM 2013 Template

Dynamics CRM 2013 Template

So I get “Connect to Dynamics CRM Server” window whenever I open the solution, which allows me to connect my CRM Organization.

Connect to Dynamics CRM Server

Connect to Dynamics CRM Server

Later I added a new “Class Library” project to my solution.

Now surprisingly when I open the solution, I am not getting “Connect to Dynamics CRM Server” window also from ‘Tools’ Menu.


  • I opened my solution file (.sln) using notepad and observed below ‘Global Section’ is missing and overridden by newly added Project details.

GlobalSection(CRMSolutionProperties) = preSolution

SolutionIsBoundToCRM = True



  • Add the ‘Global Section’ back to solution file using Notepad and Save it.
Global Section

Global Section