Tuesday, November 30, 2010

Workflows - Behind the scene

We were recently working on designing a tool that deletes workflow job. We thought it would be easy to just filter out all job that related to a workflow by the workflow id and then delete that’s it.

But like always we were in for a surprise. Just thought putting it down would help others in resolving this mystery.

Each Workflow has a unique id just like any other entity. But if you search for workflow jobs using this id to look for all jobs related to this workflow, you would be in for a surprise. It would not return all of the jobs that you are expecting. The reason being each time you revise a workflow i.e unpublish and publish the workflow once again, it creates a new workflow entry in the tables. If you want to look for the workflow jobs related to a particular workflow then you need to look for the workflow id assigned to each of its versions.

For workflow, you would find the following definitions available in the tables.


There will be only 1 definition record in CRM for a workflow no matter how many times you revise it.


But each time you publish a workflow it will create a new activation record.


The activation workflow record will have its parent workflowid set to the workflow definition id.

The workflow definition record will store the id of the currently active version of the workflow.

If you unpublish a worklfow and publish it again, it will add another row to the table and the status would now be as follows:


Note the activeworkflowid of the Definition record now refers the Guid of the latest version of the workflow that is published.

Now if you want to look for system jobs for this workflow, you will need to search for jobs that have their workflowactivationid set to any of the workflowid listed above in the table.

Hope this helps you find your way through the maze of workflows!!!

Tuesday, November 23, 2010

Debug script in Microsoft Dynamics CRM

In Internet Explorer 8 (IE 8 )Microsoft provided a way to debug the scripts.

With Internet Explorer 8 and JScript Libraries, debugging scripts has become much easier. To debug the script, Please follow the step below.
  1. When working with Microsoft Dynamics CRM try to reproduce the conditions where an error is occurring press F12 to open the Internet Explorer developer tools.


  2. On the Script tab, to the right of the Start Debugging button, use the drop-down to locate your JScript library.


  3. Set a breakpoint by clicking on the left margin within your function.

  4. Click Stop Debugging to stop debug.


  5. If your script is in the Onload event, you may need to select the Microsoft Dynamics CRM window and press F5 to reload the window.
For more information, see the MSDN topic Debugging Script with Developer Tools. http://msdn.microsoft.com/en-us/library/dd565625(VS.85).aspx

Hope this helps!

Friday, November 19, 2010

CRM 2011 - Dialogs Explored

Dialogs are the new feature addition to CRM 2011.

Just like we had the ability to extend CRM using plugins and workflows, we now have the option of Dialogs as well.

What is different in Dialog?

Dialog runs synchronously like the Plugins but they have the option of providing user interface to accept custom information required for processing.

I took an example of a situation where, you want to add custom logic that will do the following if the user tries to make an Account inactive.

  1. Check if it has a parent account associated with it, if so let the user know about it

  2. Confirm if they want to de-activate the parent account as well.

  3. If yes go ahead and de-activate it

  4. Check if the account has Child accounts associated with it, if so let the user know

  5. Disable the Child accounts as well if the users wants.

Dialogs let you design a wizard like user interface for user input. In this example we have tried to use all the features that the dialog offers. The aim here is to demonstrate the various features of Dialogs.

Check if it has a parent account associated with it, if so let the user know about it

This can be done through the if condition that was available within workflows as well.

Confirm if they want to de-activate the parent account as well.

Here we shall make you of the Page feature that has been added within dialogs. We shall design a user interface that will ask the user the question and get the Yes/No response back.


For response we have set the type to be Option Set (Radio button). We have defined the values as Yes and No.

This page is then called from the Dialog as the next step


If yes go ahead and de-activate it

We can check the user response to our question in the earlier step and based on that proceed further. Here we have called another Child workflow that is designed to de-activate the account passed to it. The parameter can be passed by selecting the attribute of the Account entity on which the workflow needs to be executed.


Check if the account has Child accounts associated with it, if so let the user know

We need to design a query that will let you search for child accounts.

Here is the trick to designing a parameterized query. When designing the query, user the like condition and specify a dummy name in the query as shown below


There after switch to the Define fetch XML query text tab.


Change the query value to Variable1%. Once you write that, you have the Variable1 showing up on the XML values section. There select the Account Name attribute of the account entity.

This will now search for accounts where parent account = current account.

To see if the query returned results, use the following condition


Disable the Child accounts as well if the users wants

The dialogs do not allow us to loop through the query results and perform action on each of the record found. But it supports calling of Workflows. So the last step is performed by making a call to a workflow assembly.


You can pass the responses received from the user on a page designed in the dialog to the Custom Workflow Assembly.


Dialogs are fun and if put to correct use, it is a very strong tool that has been provided to us.

Wednesday, November 3, 2010

Displaying CRM emails using SSRS 2008

Email body in Dynamics CRM is stored in HTML format and when we try to display the data as is in the SRS report, it shows up with all the HTML tags.
Microsoft Dynamics CRM reports strip the HTML content and display it in Plain text format.
Now with SSRS 2008, you can display them with part of the HTML formatting. It does not support all the HTML tags as yet, but some basic tags are supported that help provide a presentable view of the email body.

Let’s take an example, we will create sample email as shown below.


To show same content in SSRS report 2008 we need to follow the below steps:

  1. Place a textbox control on report and within it place the PlaceHolder by right clicking inside textbox and choose PlaceHolder.

  2. Set the properties of the 'PlaceHolder', change Markup type to HTML.

  3. Extract description(body) of email by query eg. Select description from filteredemail where activityid='A0773451-3DE3-DF11-9EAB-0003FFD4167C'

  4. Set the expression value of the placeholder to description, from dataset fields.( For e.g. Fields!description.Value).

  5. Review the report to see the following result.



Hope this helps...Time to move on to SSRS 2008!