Custom Workflow Assembly

What are Custom Workflow Activities?

  • Custom Workflow Activities can be added to an existing workflow to provide additional functionality in Workflows in CRM.
  • Workflow Assemblies are included in steps of a workflow designer where input parameters can be provided to the same to carry out its designated functionality.
  • Required Assemblies are Xrm.Sdk and Microsoft.Xrm.Sdk.Workflow
  • Custom Workflow Activities can be written by deriving CodeActivity class in your workflow assembly.

class

  • Custom Workflow Activities have Input and Output parameters that take and give out data to the workflows.
  • protected override void Execute(CodeActivityContext context){ //Activity code} needs to be initialized to add functionality to a Workflow Assembly.

Registering a Custom Workflow Assembly.

  • Custom Workflow Activities are registered in Plugin Registration Tool.
  • They are not registered on a particular entity or on any message, like a Plugin.
  • Registered Custom Workflow Assemblies then appear in the workflow step designer.
  • We can specify the Name of the workflow and the WorkflowActivityGroupName in the Plugin Registration Tool as shown below.

registerAssembly

 

 

 

Input and Output Parameters of a Workflow Assembly. 

  • Here is an example of how we can declare an input parameter to a custom workflow assembly as follows:

dateTimeIP

  • A default value can be provided along with declaring the Argument.
  • Same way, we can add Output parameters to the custom workflow assembly as below.

moneyIP

 

  • Or even declaring the Argument as both, input and output argument which is as follows:

intIP

Attributes and Microsoft Dynamics CRM Types.

  • Bool
  • DateTime
  • Decimal
  • Double
  • EntityReference
  • Int
  • Money
  • OptionSetValue
  • String

So, that was a short and quick introduction about Custom Workflow Assembly! Hope this is helpful. 🙂

 

Advertisements

Dialogs in Dynamics CRM 2013

Introduction

  • Dialogs are a collection of pages which contains a set of Prompts and Responses.
  • Dialogs are synchronous.
  • Dialogs need to be initialized by the user using the CRM Online system.
  • Requires user input at stages to run to completion. Much like a wizard.

Components of a Dialog

newProcess

Page:

  • It is a basic unit of a dialog. More like a visual container. Usually there are multiple pages in a Dialog that guide the user through a process to get certain tasks done.
  • Each page can have multiple prompts and responses.

Prompt & Responses:

promptAndResponse

A Prompt asks a question to the end user and captures response.

Response has a data type that is provided in order to specify what input should be fetched by the system. They are:

  • None – No response is required. Used for introductory purposes.
  • Single Line – A single line of text, integer or float values. A textbox is displayed to fetch this.
  • Radio button – Predefined responses shown to select only 1 among them.
  • Picklist – A drop down menu.
  • Multi-Line of text – Multiple lines of text input is supported.
  • Date and Time – Date & Time input used like in CRM forms.
  • Date Only – only date can be selected.
  • Lookup – Specifies an entity record.

 

The user response for each Prompt and Response step is stored as a step variable, and can be used later in the dialog flow.

 

Static and dynamic hyperlinks can also be added. For static hyperlinks, you need to specify the full URL. Dynamic hyperlinks, however, can be used in any text field. These hyperlinks refer to an entity record in CRM.

 

Tips help in specifying information for each prompt and response that helps the user in responding to the prompt. Tips are optional.

 

Input Arguments and Variables

Two more important components in Dialogs.

Input Arguments

  • Input Arguments are used to pass data between parent and child dialogs.
  • Input Arguments are defined for the child dialogs and data is passed onto them. This is linked by adding a Link Child Dialog step in the parent dialog. And then, the required responses can be mapped with the input arguments in the child dialog.
  • Simple arithmetic and string operations can be carried out by using Assign Value.
  • Default value for input arguments must be specified while declaring them.

 

 

Variable

  • Variables allow us to store intermediate values such as strings or computed values.
  • Intermediate values are responses that are gathered along the run of a dialog.
  • These variables are stored respective Prompt and Response

 

Comments

  • Comments are the notes that appear at the bottom of a dialog that are displayed during the run of the dialog.

 

Limitations

A link child dialog cannot be an intermediate step.

Number of nested steps in a child dialog is limited. Depends on the browser in use. Because these nested steps in browser are nested tables.

There are a few workarounds for nested steps limitations in case they happen to gray out:

  • Redesign the dialog to use fewer nested steps.
  • Add a child dialog to reduce the number of steps in parent dialog.
  • Use a different browser.

 

Actions that can be taken on Dialogs

Dialog Related Activities

These activities were first introduced in MS Dynamics CRM 2013 and are available as steps in MS Dynamics Process Designer.

 

Query CRM Data

Enables us to define query variables that can be used to query CRM data. These query variables can either have pre-defined values or can be parameterized so that they accept values at runtime.

queryCRMData

We can parameterize a query variable by using ModifyQueryVariables tab on the Define Query page, and then use the dynamics section on the query form to associate the prompt and response variables with the query variables.

 

Query Variable defined using the Query CRM Data is available for all prompts and responses from the point where they have been defined in the dialog definition.

Assign values

Allows simple arithmetic operations like increment, decrement and multiply and string concatenation operations on the input variables.

Can also be used to clear any values that is stored in the variables or input parameters.

Link Child Dialog

A dialog can be specified as a child dialog and then can be invoked from other dialog which will be its parent dialog.

Stop Dialog

Enables to end a dialog at a particular stage. Can also be used in conditions where we need to stop the dialog.

 

Workflow related activities

Workflow related activities like Create Record, Update Record, Delete Record, AssignRecord, Send e-mail, start child workflow and change status.

 

Start a dialog using a URL

An activated dialog can be started using the following URL format:

http://CRMServer_Name/Org_Name/cs/dialog/rundialog.aspx?DialogId=DialogID&EntityName=EntityLogicalName&ObjectId=EntityObjectId

 

where,

CRMServer_Name is the name of your CRM server.

Org_Name is the organization name

DialogId is the GUID of the dialog you want to run.

EntityLogicalName is the Entity Logical Name of the Primary Entity of the dialog you want to run.

EntityObjectId  is the GUID of the primary entity record.

An example of the same is as follows:

http://crmserver/AdventureWorksCycle/cs/dialog/rundialog.aspx?DialogId=9F53D2D8-AC54-46A6-A190-F23DE6677C65&EntityName=contact&ObjectId=41D1884E-B4B6-DF11-BF5E-00155DB05986

 

Conclusion

Dialogs enable us to trigger guided process. Input parameters and variables can be manipulated with during the process and also fetches CRM data. Dialogs are user interactive processes which prompts for messages and requests and fetches responses to be used in the processes.

SiteMap Customization in CRM 2013

What is a SiteMap?

  • The SiteMap is a node in the xml file of an exported unmanaged solution.
  • Navigation using SiteMap is evaluated with our Security Privileges to access a particular Entity in order to display it in the Navigation Menu.
  • If security privilege does not let us ‘Read’ a particular entity which is in the sitemap, the navigation item is not displayed.

 

Editing the customizations.xml file

  • The file can be fetched from an exported unmanaged solution.
  • We can edit this by using even a simple text editor. But it is recommended that it should be edited in a proper XML schema validator tools.
  • To reflect the changes, import the updated file back in the CRM. In case of any errors, CRM won’t let it get imported and the error message will be shown.

 

Components of the Navigation Pane

There are default areas on the navigation bar consisting of SFA (SALES), CS (SERVICE), MA (MARKETING), Settings (SETTING), and HLP (HELP).

navPane

Once an area is selected, it comes besides the main Microsoft Dynamics CRM button. And hovering over that shows a menu that appears at the bottom. This menu contains the subareas divided into different groups.

entityPane

Configuration options available using SiteMap

  1. Edit Labels
  • The text displayed is default sitemap uses ResourceId attribute to specify the text. This attribute, however, should not be changed or removed.
  • We can use <Titles> (SiteMap) or <Title> (SiteMap) elements instead to specify the txt we want to use for the organization/solution.
  • Title elements will override ResourceId attribute values.

 

  1. Add/Change Icons
  • <Area> (SiteMap) and <SubArea> (SiteMap) has a 16×16 icon that is displayed on the navigation. PNG, GIF, JPG image web resource are supported.
    While including the image as a web resource, use ‘$webresource’ directive. This will create a dependency and the web resource will not be deleted until the SiteMap element uses it.

 

  1. Add/remove elements
  • Copy pasting existing XML elements is recommended as it helps reduce writing erroneous code.
  • In case of removal of elements, the fact that whether changing the security privileges will serve the purpose should be considered.
  • It is recommended to use security privileges to an area/subarea instead of removing elements.

 

  1. Group Links within Areas
  • <Group> (SiteMap) is used to create groups. For this, <Title> (SiteMap) and <Description> (SiteMap) is used for it to be displayed as a group.
  • Then, edit <Area> (SiteMap) element to add the ShowGroups attribute to True.

 

  1. Adding New pages to an Area.
  • We can also include Web pages in the navigation bar. For that, <SubArea> (SiteMap) must be used in order to add new pages to an area.
  • To display a custom page in the application, use Url attribute instead of Entity This Url should contain the directive ‘$webresource:’ followed by the location of the HTML web resource. As discussed earlier, using the web resource directive will prevent it from being deleted by forming a dependency. So that it is available whenever the SiteMap requires it.

 

Manually Editing the SiteMap

exportSolution

  1. The SiteMap firstly needs to be added into the unmanaged solution. This can be done by navigating to Settings > Customizations > Solutions. Then, in Client Extensions, include the SiteMap.
  2. Save the solution and chose to export the solution. A zip file will be downloaded. By extracting its contents, find xml file. SiteMap can be edited using this file.
  3. Find <SiteMap> tag to edit the SiteMap.
  4. Create a new zip file, include the extracted solution with the edited xml file.
  5. In Solutions in CRM 2013, include the zip by choosing it to import as a solution. Finally, publish the customizations and refresh the page to see the modifications.

 

IMPORTANT

Encode the Ampersand Character.

When there is an ‘&’ in the URL used in the SiteMap, replace it with “&amp;”. Without this, the XML validation fails and the solution will not be imported.

 

Example from SDK 2013:

       

          Correct:

<SubArea Id=”new_customSubArea” Url=”http://mysite/mypage.aspx?parameter1=value&amp;parameter2=value “>

Incorrect:

<SubArea Id=”new_customSubArea” Url=”http://mysite/mypage.aspx?parameter1=value&parameter2=value”&gt;

 

Errors while importing SiteMap

  • The import tool takes care of the XML validation. In case of any errors, the default SiteMap is updated and an error message is thrown. In this case, we must rectify the errors and re import the solution.

 

XML Elements used in SiteMap

  1. <Area> (SiteMap)

Contains the Areas which appear on the CRM 2013 Navigation Pane.

The syntax is as follows:

 

<Area URL=”” Id=”” ShowGroups= true|false>

<Titles><Descriptions><Groups>

</Area>

 

The attributes are as follows:

DescriptionResourceID – For internal use only.

Icon  – A 16×16 resolution image that is shown in the button.

Id – unique identifier in ASCII. Spaces are not allowed.

ResourceId – for internal use only.

ShowGroups – Boolean value to choose whether groups of sub-areas are shown in the navigation pane.

Title – Deprecated. Use <Titles> (SiteMap) and <Title> (SiteMap).

Url – Specifies the CRM for Outlook URL to render for the Outlook folder that represents the Area.

 

 

Child Elements – <Titles> (SiteMap), <Descriptions> (SiteMap), <Group> (SiteMap)

Parent Elements – <SiteMap> (SiteMap) – root node.

myArea

  1. <SiteMap> (SiteMap)

Defines the root node of the SiteMap used for Navigation.

The syntax is as follows:

 

<SiteMap Url=””>

<Area />

</SiteMap>

 

The attributes are as follows:

Url – Specifies the URL for CRM for Outlook to render.

 

Child Elements- <Area> (SiteMap)

Parent Element- <SiteMap> (ImportExportXml) the container node for <SiteMap> node within the customization.xml file.

 

siteMapTag

  1. <Titles> (SiteMap)

Specifies a set of localizable titles for the parent element.

 

<Titles><Title / ><Title>

 

No attributes are present for this element.

Child Element – Specifies the text in a specific language to be displayed for the parent of the Titles element.

Parent Elements – <Area> (SiteMap), <Group> (SiteMap), <SubArea> (SiteMap).

 

  1. <Descriptions> (SiteMap)

Specifies a set of localizable descriptions for the parent element.

 

<Descriptions><Description /></Descriptions>

 

No attributes are present for this element.

Child Element- <Description> (SiteMap)

Parent Element – <Area> (SiteMap), <Group> (SiteMap), <SubArea> (SiteMap)

 

  1. <Title> (SiteMap)

Provides  a title in a specified language for the parent element i.e. <Titles> (SiteMap)

The syntax is as follows:

<Title LCID=”” Title=”” />

 

The attributes are as follows:

LCID – 4 or 5 digit Locale ID for a title.

Title – Text to be displayed.

 

No child elements exists for this tag.

 

Parent Elements- <Titles> (SiteMap)

 

 

  1. <Description> (SiteMap)

Provides  a description in a specified language for the parent element i.e. <Descriptions> (SiteMap) element.

The syntax is as follows:

 

<Descriptions LCID=”” Description=”” />

 

The attributes are as follows:

LCID – 4 or 5 digit Locale ID for a description.

Description – Text to be displayed.

 

No child elements exists for this tag.

 

Parent Elements- <Descriptions> (SiteMap)

 

  1. <SubArea> (SiteMap)

Specifies a navigation option within an <Area> (SiteMap). It defines objects that will be displayed under the selected application.

 

<SubArea

AvailableOffline=[“0”|”1”|”true”|”false”]

CheckExtensionProperty=””

Client = [“All” | “Outlook” | “OutlookLaptopClient” | “OutlookWorkstationClient” | “Web”]

DescriptionResourceId=”” Entity=”” GetStartedPanePath=”” GetStartedPanePathAdmin=”” GetStartedPanePathAdminOutlook=”” GetStartedPanePathOutlook=”” Icon=”” Id=”” License=”” OutlookShortcutIcon=”” PassParams=[“0” | “1” | “true” | “false”]

ResourceId=”” Sku=[“All” | “OnPremise” | “Live” | “SPLA”] Title=”” Url=””>

 

<Titles / >

<Descriptions / >

<Privilege / >

</SubArea>

 

The attributes are as follows:

AvailableOffline – Whether SubArea is available offline.

CheckExtensionProperty – Internal use only.

Client – Default. Mulitple specified values can be used.

DescriptionResourceId – Internal use only.

DefaultDashboard – Specifies the GUID of the default dashboard.

Entity – Specifies the value of an Entity.

Icon – Consists of an 18×18 icon image.

Id- Unique identifier.

OutlookShortcutIcon – Specifies the outlook icon used.

PassParams – Specifies whether the organization information and language context passed to the URL.

ResourceId – For internal use only.

Sku – Specifies the versions of MS Dynamics CRM that displays this SubArea.

Url – Specifies a URL of a web resource to display in the main frame of  the application when this subarea is selected.

 

Child Elements- <Privilege> (SiteMap)

Parent Elements – <Group> (SiteMap)

 

newPersonalArea

 

  1. <Group> (SiteMap)

Holds a group of SubAreas

The syntax is as follows:

 

<Group DescriptionResourceId=”” Icon=”” Id=”” IsProfile=[“0” | “1” | “true” | “false”] ResourceId=”” Title=”” Url=””>

<Titles/>

<Descriptions/>

<SubArea/>

</Group>

 

The attributes are as follows:

DescriptionResourceId – For internal use only.

Icon – Unused.

Id- Unique identifier.

IsProfile – Controls whether this Group represents a user selectable Profile for the workplace.

ResourceId – For internal use.

Url- URL to render for the Outlook folder that represents the Group in CRM for Outlook.

 

Child Elements – <Descriptions> (SiteMap), <SubArea> (SiteMap), <Titles> (SiteMap)

 

Parent Elements – <Area> (SiteMap)

 

  1. <Privilege> (SiteMap)

Controls whether a subarea displayed based on privileges available in any security role assigned to a user.

 

<Privilege Entity=”” Privilege=[Read|Write|Append|AppendTo|Create|Delete|Share|Assign|All|AllowQuickCampaign|UseInternalMarketing] />

 

The attributes available are as follows:

Entity- Specifies the entity to check the privileges for.

Privilege – Privilege to check.

 

No child elements are present.

 

Parent Elements – <SubArea> (SiteMap)

 

Pass Parameters to a URL Using SiteMap

We can pass organization information and language context of the user and the language context of the organization for the target application by using PassParams attribute of the <SubArea> (SiteMap)

 

Parameter-

orgname – Organization Name

userlcid – User Language Code. eg. 1033 for English

orglcid – Organization language code. Eg. 1033 for English.

 

Without Parameters –

http://myserver/mypage.aspx

With Parameters –

http://myserver/mypage.aspx?orgname=AdventureWorksCycle&userlcid=1033&orglcid=1033

 

Conclusion

SiteMap Customizations are carried out with the basic requirement to show the navigation pane in a customized manner to user who have different access privileges to different CRM data.

Hope it helps!

 

Duplicate Detection in CRM 2013

What is Duplicate Detection feature?

  • In order to maintain integrity in data in our system, it is a good practice to reduce duplicate data. To do so, MS Dynamics CRM provides facility to do so.
  • Duplicate Detection needs to be enabled from Settings > Data Management > Duplicate Detection Settings.
  • Default duplicate detection rules are defined for accounts, contacts and leads but not for other types of records. To enable duplicate detection on other types of records, we need to create new rules.

 

Enable Duplicate Detection

  • We can enable Duplicate Detection for our organization under Settings > Data Management > Duplicate Detection Settings as shown below.

duplicateDetectionSettings

 

  • As shown above, Duplicate Detection first needs to be enabled organization wide.
  • Then we can chose on what the duplicate detection should be enabled.
    1. When a record is created or updated.
    2. When the CRM for outlook goes from offline to online and,
  • 3. During data import

 

Duplicate Detection Rules

  • There are predefined rules already available in Duplicate Detection Rules for account, lead and contact.

duplicateDetectionRules

 

  • Likewise we can create new rules of our own with certain criteria to run of other types of records. In order to create new rules, select New.
  • For the new Duplicate Detection Rule, give a suitable name. Set Base Record Type to the entity you want the duplicate detection rule to run on. And provide Matching Record Type to compare the record to for the rule to run.

 

matchingRecordType

 

  • We can optionally chose to compare with having the Case-Sensitivity and to Exclude inactive matching records.
  • In the above example, we want to detect duplicate records with same customer name being created on Employee. So, we’ll set the criteria for our rule to run the duplicate detection.

criteriaForDuplicateDetection

 

  • In the example above we have 2 criteria for the duplicate detection rule to run. These criteria are ANDed i.e. both should satisfy to detect duplicate records successfully.
  • First, we are comparing the Name for its exact match and then we are checking the Address for its first 5 characters to be the same.
  • We can also optionally chose to ignore blank values. In this case, we are not doing so.
  • Once done, we can Save and Close the duplicate detection rule.
  • So, our newly created rule appears in the list of Duplicate Detection Rules. It hasn’t been published yet. So it won’t detect duplicated unless we Publish it.
  • publishDDRules

 

  • To do so, select the rule we just created, and Publish it.
  • Let’s check the duplicate detection rule we just published.
  • example1Now, We have 2 records in employees Andrew and Samuel. We shall try to create another employee named Samuel with same address to force CRM to detect a duplicate on creation of a new Employee record.
  •  On saving this record, CRM will throw a warning that it detected duplicate of the record that we are trying to create.

 

duplicatesDetected

 

  • So here, it has detected a duplicate records that matched the rule we created for name and address of the Employee. If we want the duplicate record to be created nonetheless, we can click on Save to do so.
  • Cancelling it will avoid the duplicate record being created and we can go back to our record to change it before it is saved.

 

Hope it helps you! 🙂

 

Another post on Duplicate Detection jobs is coming up soon. Will update you once done. Keep checking this area. Thanks!

 

Access Teams in CRM 2013

What are Access Teams?

  • Access Teams are light-weight teams aimed at high volume sharing scenarios.
  • These are designed to address the concerns of the overhead of calculating security roles when needed.
  • Access Teams can be automatically created and managed.
  • Access teams can’t be granted security roles and they can’t own records.
  • They only access records through sharing.
  • Sharing privileges are defined by an access team template. They don’t change dynamically for existing records if the template changes.
  • Access Teams can’t be used as resources in Service Scheduling.

Access Teams, however, can be created manually through Teams interface in Settings > Administration.

 

Creating an Access team

  • An Access Team first needs to be enabled from an Entity level. To do so, navigate to Customizations > (Entity). We can consider an example of a custom entity, say Customer.

Enable Access Team on Entity

The checkbox on Access Teams needs to be checked to be able to enable Access Teams for Customer entity.

  •  Then, we navigate to Settings > Administration > Access Team Templates. And select New template.

Enable Access Team on Entity

Give a meaningful Name to the template that will be identified. Select the entity from the Entity dropdown that we enabled Access Teams for at the Entity level.

We can provide desired access rights as mentioned above from Delete, Append, Append To, Assign, Share, Read and Write.

  •  Now you Access Team template has been created. Next, we shall add a sub-grid to the Customer form that will access this template. And Set Properties as follows for the Sub-Grid on the form.

As shown below, set the following properties for the Data Source of the sub-grid,

Records to All Record Types

  • Entity to Users
  • Default View to Associated Record Team Members

And

  • Team Template to Customer List Access (This is the Access Team Template you just created)

Access Team Template Set Properties

The sub-grid now is set to add users to the Access Team that will use the access rights we set in the Access Team Template.

Access Team Subgrid

 

  • Once the record is created, you can add Users to the sub-grid that will have access to that particular record and which will have access rights as defined in the template.

As in the above form, the 2 users have access to the record with name Ashwin V. with the access rights Append, Append To, Read and Write.

 

 

How Access Teams work?

  • Whenever Access Teams are enabled for an entity, the team’s lifecycle is managed automatically.
  • So when the first member is added to the Access Team grid, an access team is created and the first member is granted the access rights as specified.
  • Then as members are added and removed, access to those members are added and removed respectively.
  • When the final member of the access team is removed, the team gets deleted. This marks the end of the Access Team lifecycle.
  • Deactivating the record, however, won’t affect the access team. Only adding and removing members from the access team will cause deletion of automatically generated access team.

 

Viewing the Access Teams

  • In normal operation, access teams are created automatically. Hence, they are system generated and are deliberately hidden from users.
  • In order to view these access teams, use ‘Advanced Find’ option to query for Teams of type Access and Is System Managed as Yes, No.
  • This will show both access teams, automatically created and system generated as shown in the figure below.

Viewing Access Teams

Access Teams Guid

The automatically generated access teams are named as their GUID.

Migrating to Access Teams

Teams that have been migrated from older version will be migrated as owner teams. It’s possible to convert them to access teams under the following conditions:

  1. The owner team doesn’t have any security roles, and
  2. The owner team isn’t the owner of any records.

Convert To Access Teams

The CONVERT TO ACCESS TEAM button will convert the owner team into an access team once the above said criteria is matched.

 

Programmatic control of access teams

  • Remember, an access team is actually created when we add the first member to the access team. So we need an existing team to add a team member to it.
  • A new SDK message is introduced to handle this scenario. AddUserToRecordTeamRequest.
  • Using the said SDK message, we need to specify the record and team template that the user should be added to. This will resolve the request to the access team that is relevant and, if necessary, create the team before adding the user as a member.
  • When working with system generated access teams, this message should be considered for adding users as team members.

So, that’s it! Hope you find this useful. 🙂