61 Wednesday, January 4, 2017 |
Suresh Maurya
Dynamics CRM Consultant at IBM

Lead Management: Creating Lead

To create a new Lead and view its properties follow these steps:

  • On the Navigation Bar, click Sales and then click Leads
  • In the Ribbon click New, to open new record.
  • In the Lead form enter following information:
    • Topic
    • First Name
    • Last Name
    • Job Title
    • Company Name
    • Email
    • Mobile Phone
    • Description
  • Click Save
  • Now Lead is created

Microsoft Dynamics CRM Working with Solutions

Getting Started with Dynamics CRM 2011

Classifying Accounts with Many-to-Many Relationships

Sometimes a single-valued picklist is sufficient to classify records like accounts in Dynamics CRM, but sometimes it's not. In this video I talk about why and how you might want to use many-to-many -- N:N for short -- relationships, and demonstrate how to implement them in Dynamics CRM 2011.

Associate Records In Microsoft Dynamics CRM Using Early Bound

Associate Method

To associte records in Microsoft Dynamics CRM use IOrganizationService.Associate(entityName, Guid, Relationship, EntityReferenceCollection) method.


Name Type Comment
entityname String Entity logical name
guid Guid The ID of the record to which the related records are associated.
relationship Guid The name of the relationship to be used to create the link.
relatedEntities Guid A collection of entity references (references to records) to be associated..



This method is implemented by OrganizationService class and OrganizationServiceContext generated in previous chapter.

Using Early Bound 

Following example demonstarates how to associate a contact with three accounts in Microsoft Dynamics CRM using early bound


// Associate the accounts to the contact record.

// Create a collection of the entities that will be 
// associated to the contact.
EntityReferenceCollection relatedEntities = new EntityReferenceCollection();
relatedEntities.Add(new EntityReference(Account.EntityLogicalName, _account1Id));
relatedEntities.Add(new EntityReference(Account.EntityLogicalName, _account2Id));
relatedEntities.Add(new EntityReference(Account.EntityLogicalName, _account3Id));

// Create an object that defines the relationship between the contact and account.
Relationship relationship = new Relationship("account_primary_contact");

//Associate the contact with the 3 accounts.
_service.Associate(Contact.EntityLogicalName, _contactId, relationship,

Console.WriteLine("The entities have been associated.");

//Disassociate the records.
_service.Disassociate(Contact.EntityLogicalName, _contactId, relationship,

[Job] - Accenture: Microsoft Dynamics CRM, India


Company: Accenture

Location: Hyderabad

- Job description

"Role:- Developer
Years of experience:- 3 to 4 years
Must to have:-
• Plug-in - custom workflow activities, ribbon customizations, Silverlight, CRM Developer Toolkit
• Exposure to any development framework
• Should be able to create and debug Plugins - Should be able to create and debug Custom Workflow activities
• Should be able to do Ribbon customization - Understanding of Solutions - Understanding of the security in Dynamics CRM
• Should have understanding of using Developer Toolkit for Dynamics CRM
Good to have:
• Strong design and development skills
• Ability to design and develop flows
• Effectively communicates to internal and external stake-holders"

- Basic qualifications

Full Time Graduation

Processes/Workflow Ownership Mystery in Microsoft Dynamics CRM

Under what user’s context does the workflow execute? (If the workflow creates a record, who will be the owner of that new record?)

It depends. Automatically triggered workflows (such as a workflow that triggers on account create) will execute in the context of the owner of the workflow. Therefore, if you have a send email step, the email will be by default sent from the e-mail account of the workflow owner. This is important to consider because the workflow owner might belong to a different business unit and have different privileges than the user who triggered the workflow (e.g. who created the account). Let’s say your workflow creates a task each time an account is created. Depending on the privileges of the user, the task might be in another business unit and not visible to the user, therefore you should consider adding an “assign step” that assigns the new task to the owner of the account. Now, if the workflow is executed on-demand, the workflow will then execute in the context of the user who requests the workflow execution. Because dialogs are always on-demand then they always execute in the context of the user who started the dialog.

Why does the process execute under different users depending on how it was started?

This was a design decision based on security considerations. You don’t want to inadvertently be sending emails and executing actions without knowing it because some other user decided it. Therefore, by having this different behavior we can guarantee that the user under which the workflow executes is always aware that a workflow is performing some actions on his behalf. For the automatic workflow case, the owner of the workflow is also the person who activates it and who selects the trigger mechanism and the workflow steps so it is OK if the workflow executes under that user’s context. For the on-demand case, a user is specifically requesting some actions to be performed on his behalf by a workflow so the user is fully aware of the workflow definition and that it will execute; therefore it is safe to execute the workflow under that user’s context instead of the workflow owner (who might not be aware that a user requests an on-demand execution).

Why can’t I activate/deactivate someone else’s workflow, even if I am the system administrator?

For the same security reason as explained above. You want the workflow owner to explicitly acknowledge that a workflow will be activated and will perform some actions on his behalf. You would not want to allow another user (even the system administrator) to decide that some process should be executed on another user’s behalf. If you want to activate/deactivate someone else’s process you must first assign it to yourself.

If I assign an activated process to another user, why does the user have to re-activate it?

Active processes cannot be modified so the system automatically deactivates them before assigning it to the new user. As per Q3 above, only the new owner will be able to re-activate the process.

I am importing a solution that contains processes and it fails with this error message “The workflow cannot be published or unpublished by someone who is not its owner”. What is wrong?

If your solution contains a process that already exists in the organization and is activated then solution import will attempt to update it. In order to do so, it must first deactivate it. However, if the owner of the activated process is not the same as the user who is importing the solution, then deactivating the process will fail (see Q3). Therefore you have a few options to fix this problem:

  1. Import the solution using the user who owns the activated process. This can be tricky, especially if there are multiple processes owned by different users which need to be updated by the solution import.
  1. Verify which processes are included in the solution, and then find them in the organization, if you can find them and they are not owned by you then you must assign them to yourself. You can reassign them to the original user after you import the solution; however, you will have to ask the process owners to activate it themselves.

Discovery Web Service in Microsoft Dynamics CRM

Discovery Web Service

The Discovery web service is used to determine the organizations that a user is member of, and provides the Organization service endpoint URL for each of those organizations which is further used to connect to specific organization.

It is required because Microsoft Dynamics CRM is a multi-tenant application i.e. a single deployment can host multiple instances of CRM.

Key points about Discovery service

  • It implements IDiscoveryService interface.
  • It is built on Window Communication Foundation (WCF).
  • It can provide information such as 
    • Organization friendly name
    • URL endpoints
    • Unique id of organization
    • version
    • Unique name
    • Current state (disabled or enabled)

Discovery service usage:

  • To determine the organizations a user is member of in a muti-tenant environment.
  • To determine the endpoint urls of those organizations.
  • In a data center server details of organizations can change because of maintenance or load balancing, therefore hard-coding organization url is removed.

Discovery service endpoint URLs:

The following table lists the Web service URLs for the worldwide Microsoft Dynamics CRM Online data centers.

Location Discovery Web service URL Identity Provider
North America https://dev.crm.dynamics.com/XRMServices/2011/Discovery.svc Microsoft account
  https://disco.crm.dynamics.com/XRMServices/2011/Discovery.svc Microsoft Office 365
North America 2 https://disco.crm9.dynamics.com/XRMServices/2011/Discovery.svc Microsoft Office 365
Europe, Middle East and Africa (EMEA) https://dev.crm4.dynamics.com/XRMServices/2011/Discovery.svc Microsoft account
  https://disco.crm4.dynamics.com/XRMServices/2011/Discovery.svc Microsoft Office 365
Asia Pacific Area (APAC) https://dev.crm5.dynamics.com/XRMServices/2011/Discovery.svc Microsoft account
  https://disco.crm5.dynamics.com/XRMServices/2011/Discovery.svc Microsoft account
Oceania https://disco.crm6.dynamics.com/XRMServices/2011/Discovery.svc Microsoft Office 365
Japan (JPN) https://disco.crm7.dynamics.com/XRMServices/2011/Discovery.svc Microsoft Office 365
South America https://disco.crm2.dynamics.com/XRMServices/2011/Discovery.svc Microsoft Office 365
India (IND) https://disco.crm8.dynamics.com/XRMServices/2011/Discovery.svc Microsoft Office 365

For an Internet-facing deployment (IFD) installation, the Web service URL has the following form:

https://dev.< hostname[:port]>/XRMServices/2011/Discovery.svc

For an on-premises installation, the web service URL has the following form:

http[s]://< hostname[:port]>/XRMServices/2011/Discovery.svc


The <CommandDefinition> (RibbonDiffXml) element defines a command in the ribbon. The Id attribute specifies a unique identifier for the command that can be referenced by ribbon control elements by using the Command parameter.

A ribbon command defines three things:

  • Enable Rules: Specifies when a specific ribbon control will be enabled.

When configuring Ribbon elements you can define specific rules to control when the ribbon elements are enabled. The <EnableRule> (RibbonDiffXml) element is used as follows:

  • Use the /RuleDefinitions/EnableRules/EnableRule element to define rules controlling when the ribbon element should be enabled.
  • Use the /CommandDefinitions/CommandDefinition/EnableRules/EnableRule element to associate specific enable rules to a command definition.
  • Display Rules: Specifies when a specific ribbon element will be visible.

When configuring ribbon elements, you can define specific rules to control when the ribbon elements will display.

  • Use the /RuleDefinitions/DisplayRules/<DisplayRule> (RibbonDiffXml) element to define rules controlling when the ribbon element should be displayed.
  • Use the /CommandDefinitions/CommandDefinition/DisplayRules/<DisplayRule> (RibbonDiffXml) element to associate specific display rules to a command definition.
  • Actions: Specifies what code will execute when a ribbon control is uses.

Define the actions to be performed by a ribbon control in a <CommandDefinition> (RibbonDiffXml) element together with rules that control whether the control is enabled or visible in the ribbon.

A Ribbon control can perform two types of actions and may include multiple actions:

  • JavaScript Functions: A <JavaScriptFunction> (RibbonDiffXml) element references a function defined in a Script Web resource.
  • Open a URL: The ribbon opens a URL using the value from an Address attribute in the <Url> (RibbonDiffXml) Additional parameters can pass information about how what querystring parameters are passed and the mode in which the window opens.
    You have several options to pass parameters to a URL using the ribbon. For more information, see Pass Parameters to a URL By Using the Ribbon.

Generate early bound entity classes with the code generation tool (CrmSvcUtil.exe)

CrmSvcUtil.exe is a command line tool which can generate early bound classes for Microsoft Dynamics CRM. Output file can be C# or VB.Net file.

Generated file contains 

  • All entities, one partial class for each entity
  • All attributes
  • All relationships

These strongly typed classes provide early binding and Intellisense support in Microsoft Visual Studio.

Generated file can be referenced by projects that use Microsoft Dynamics CRM. Following assemblies must also be referenced in that project

  • Microsoft.Crm.Sdk.Proxy.dll
  • Microsoft.Xrm.Sdk.dll

These assemblies can be found in SDK\bin folder of the SDK.

Running code generation tool

Make sure Microsoft.Xrm.Sdk.dll  assembly is in same folder.

For On-premises

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


For Microsoft Dynamics CRM Online

CrmSvcUtil.exe /url:https://<organizationUrlName>.api.crm.dynamics.com/XRMServices/2011/Organization.svc    /out:<outputFilename>.cs /username:<username> /password:<password>     /namespace:<outputNamespace> /serviceContextName:<serviceContextName>


Correct URL can be found at

Settings > Customization > Developer Resources

To list the supported command-line parameters, use the following command.

CrmSvcUtil.exe /?



The following table lists the code generation tool parameters and a gives a brief description of their use.







Device ID used when you connect to the Online server for authentication. Only required if the device ID has not been stored on disk in the %USERPROFILE%\LiveDeviceID folder. Only used with the Microsoft account identity provider.




Device password that is used when you connect to the Online server for authentication. Only required if the device password has not been stored on disk in the %USERPROFILE%\LiveDeviceID folder. Only used with the Microsoft account identity provider.




The domain to authenticate against when you connect to the server.




The URL for the Organization service.




The file name for the generated code.




The language to generate the code in. This can be either “CS” or “VB”. The default value is “CS”.




The namespace for the generated code. The default is the global namespace.




The user name to use when you connect to the server for authentication.




The password to use when you connect to the server for authentication.




The name of the generated organization service context class. If no value is supplied, no service context is created.




Show usage information.




Suppress the banner at runtime.




Generate request and response classes for actions.




When set to true, a dialog to log into the CRM service is displayed. All other connection related parameters specified on the command line are ignored.




Contains information, provided as a single string, for connecting to a CRM organization. All other connection related parameters specified on the command line are ignored. For more information see Use connection strings in XRM tooling to connect to CRM.



Usage Examples


CrmSvcUtil.exe /url:https://myport:555/MyOrg/XRMServices/2011/Organization.svc /out:GeneratedCode.cs /username:administrator /password:password

Microsoft Dynamics CRM Online -  Microsoft Identity Provider

CrmSvcUtil.exe /url:https://myorg.api.crm.dynamics.com/XRMServices/2011/Organization.svc /out:GeneratedCode.cs /username:"myname@live.com" /password:"myp@ssword!"

Microsoft Dynamics CRM Online -  Microsoft Office 365 

CrmSvcUtil.exe /url:https://myorg.api.crm.dynamics.com/XRMServices/2011/Organization.svc /out:GeneratedCode.cs /username:"myname@myorg.onmicrosoft.com" /password:"myp@ssword!"

Claims Authentication - IFD

CrmSvcUtil.exe /url:https://myorg.crm.com:555/XRMServices/2011/Organization.svc /out:GeneratedCode.cs /username:administrator /password:p@ssword! 


Use the Configuration File

The CrmSvcUtil.exe.config configuration file must be in the same folder as the CrmSvcUtil.exe tool.

If you enter a value at the command line, that value will be used instead of the one in the configuration file. 

Do not include the url and namespace parameters in the configuration file. These must be entered from the command line when the CrmSvcUtil.exe tool is being run.

The following sample shows how to configure the output file and the domain name parameters in the application configuration file using shortcut keys.

<appSettings> <add key="o" value="CrmProxy.cs"/> <add key="d" value="mydomain"/></appSettings>

Enable Tracing

To enable tracing when you run the tool, add the following lines to the configuration file:
   <trace autoflush="false" indentsize="4"> 
         <add name="configConsoleListener" type="System.Diagnostics.ConsoleTraceListener"> 
            <filter type="System.Diagnostics.EventTypeFilter" initializeData="Error" /> 

Microsoft Dynamics CRM 2011: Implementing Claims and IFD: Part 5

This session will cover the setup of claims with an un-trusted domain.

Color Grid for Dynamics 365

Color Form for Dynamics 365