Saturday, 6 April 2013

Dynamics CRM 2011 – Send an e-mail on a specific date

 

Currently, I came across a scenario where we had to configure a workflow to send an e-mail on a specified date value on an opportunity entity. On opportunity entity I had a date field “Date 1” and what we were required to do was to send an email to opportunity owner on a date specified in the Date 1 field value. To achieve this, I can configure a workflow with timeout or wait condition set on the Date 1 value.

First, I tried to make it work using the Timeout criteria but it seemed to fail our requirements when the date value is null. So, I decided to work with wait condition.

Following are the steps configured in workflow to meet the requirements:-

image

Step 1: Start workflow on Record Created and Record Fields change. In Record fields change select the Date1 field.

Step 2: Check if Date1 field is null. If the field is null then no need to set any wait condition.

Step 3: Since we have fired this workflow on field change also, we had to make sure that there should not be more than one workflow with wait condition. When opportunity record is created and Date 1 field contains data, a workflow record would be created in wait mode. At the same time, if somebody modifies the date 1 value for the same opportunity record then another workflow record should not be crated in waiting mode to be executed on that particular updated date value. Instead, the previously created workflow should be updated with new value. To achieve this we have taken a custom attribute here DateValue which is a two option field. Default value of DateValue is false. Once a date is entered the value of datevalue gets updated to true. This way we ensure that on field change we don’t create a new wait condition if one already exists.

Step 4: If the attribute value is false means there is no previously existing system job with wait condition. So, Add step of wait condition and set process execution time on or after the Date1 value. If the value is true means the workflow record was already created and nothing to do in that scenario.

Step 5: Add a Send Email step and configure required values.

I hope this would be helpful.

Friday, 29 March 2013

Dynamics CRM 2011 – Limitations of Report Wizard (OOB)

 

Feature List

Report Wizard (OOB)

Custom SSRS Report - BIDS

Remarks

Grouping

Yes

Yes

-

Adding extra rows and columns

No

Yes

-

Expressions Based Values

No

Yes

-

Design, Font, Colour Change

No

Yes

No option available while creating report through wizard. Is possible after exporting and changing the report.

Context specific

Yes (By Default)

Yes

-

Group Summary

Yes (With limited functions)

Yes

Average, Maximum, Minimum, Percentage of total, Sum are the summary types that can be used in report wizard for a field.

Lookup Functionality

No

Yes

-

Hyperlink

No

Yes

-

Use of Sub Reports

No

Yes

-

Charts

Yes (Limited Type)

Yes

Only vertical bar chart, horizontal bar chart, line chart, pie chart are supported in report wizard.

Tools like line, list, image, sub report, gauge, map,
indicator, sparkline

No

Yes

 

Custom Code

No

Yes

 

Functions Available in Expressions

No

Yes

 

Hide Show based on expressions

No

Yes

 

Report filters

No

Yes

 

Parameters

No

Yes

There is no way to add new parameter to the report
through report wizard.

Header - Body - Footer

No

Yes

 

Page Nos. in footer

No

Yes

 

Accessing Current Date Time

No

Yes

 

Entities could be involved in generating a report

One primary entity and it's first level related entity

No such limitation

 

I hope this would be helpful. Please feel free to comment on this post with more limitations.

Friday, 15 March 2013

Dynamics CRM - Trigger a workflow from JavaScript

 
Updated on – 24th Sep 2015
 
Recently I had a requirement to trigger a workflow on click of ribbon button when it meets certain criteria. Refer below link for calling JavaScript function from custom ribbon button.

http://ankit.inkeysolutions.com/2012/01/crm-2011-how-to-use-visual-ribbon.html

The criteria values are checked using JavaScript and if all criteria are satisfied then the workflow is to be triggered. The function below will take two inputs where entityId is the id of the record for which the workflow will execute and workflowProcessId is the id of the workflow which we want to execute.
function startWorkflow(entityId, workflowProcessId) {
  var request = "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
   "<s:Body>" +
     "<Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">" +
       "<request i:type=\"b:ExecuteWorkflowRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\" xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">" +
         "<a:Parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">" +
           "<a:KeyValuePairOfstringanyType>" +
             "<c:key>EntityId</c:key>" +
             "<c:value i:type=\"d:guid\" xmlns:d=\"http://schemas.microsoft.com/2003/10/Serialization/\">" + entityId + "</c:value>" +
           "</a:KeyValuePairOfstringanyType>" +
           "<a:KeyValuePairOfstringanyType>" +
             "<c:key>WorkflowId</c:key>" +
             "<c:value i:type=\"d:guid\" xmlns:d=\"http://schemas.microsoft.com/2003/10/Serialization/\">" + workflowProcessId + "</c:value>" +
           "</a:KeyValuePairOfstringanyType>" +
         "</a:Parameters>" +
         "<a:RequestId i:nil=\"true\" />" +
         "<a:RequestName>ExecuteWorkflow</a:RequestName>" +
       "</request>" +
     "</Execute>" +
   "</s:Body>" +
 "</s:Envelope>";
 
  var requestURL = Xrm.Page.context.getClientUrl() + "/XRMServices/2011/Organization.svc/web";
  var xmlHttpRequest = new XMLHttpRequest();
  xmlHttpRequest.open("POST", requestURL, false)
  xmlHttpRequest.setRequestHeader("Accept", "application/xml, text/xml, */*");
  xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
  xmlHttpRequest.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
  xmlHttpRequest.send(request);
}


That’s it. The above common method can be used to trigger workflow from JavaScript.

I hope this would be helpful.



Friday, 8 March 2013

Dynamics CRM 4.0 to 2011 upgrade - ISV tab dilemma

Currently, I am working on one of my projects where in I was told to develop an upgrade plan, to upgrade an organization from CRM 4.0 to 2011. The customer uses couple of third party add-ons and these add-ons have applied some changes in ISV.config file in CRM 4.0. I have prepared my lists for upgrade and started with test runs, during this time I found some unwanted ISV tab(highlighted in below screen shot) on some of the in-built and custom entities.

image

After some binging, I came to know that this is by design. All Custom Menu and Grid Buttons of CRM 4.0 would be upgraded as new tab besides Customize tab in CRM 2011. To know more about this symptom, you can refer below link.

http://support.microsoft.com/kb/2501761

There are couple of solutions which could be applied to get rid of this ISV tab as explained below,

1. You can remove these buttons from CRM 4.0 via updating ISV.config file before upgrade.

2. You can change the RibbonDiffXml part of customization xml file, as described in above link after upgrading an organization.

If you want to apply second solution then you can use Ribbon Workbench tool for CRM 2011. You can download & import this add-on with the help of below URL.

http://www.develop1.net/public/page/Ribbon-Workbench-for-Dynamics-CRM-2011.aspx

And then,

1. Create a solution with just the application ribbon in it.

2. Find the ISV tab

3. Right click on it and select 'Un-customise Tab'

4. Publish your solution.

According to my knowledge the Visual Ribbon Editor tool does not support this feature as of now.

I hope this would be helpful.

Saturday, 23 February 2013

Dynamics CRM 2011 - Unfulfilled order records – No code solution

In Dynamics CRM 2011, you have an option to fulfil an order record. Once you fulfil it you cannot modify that record further. Unlike lead and opportunity records, OOB, there is no action button on top ribbon bar that allows you to reopen the fulfilled order record. The very simple way to reopen it is to configure a workflow. One can create an on-demand workflow on order entity and change the status of the order record(s) from “Fulfilled” to “New”. Recently, one of my customers had the same requirement but with one constraint i.e. this action should be performed by users only with specific security roles. All system users cannot reopen the fulfilled orders.

To achieve this we can create our own custom ribbon button on Order record and replace the system button. There could be one configuration entity where system admin can select the security role(s) which can be validated later when user clicks on above custom ribbon button. If logged in user has any of the configured security roles then only that user can reopen an order.

However, I wished to develop this functionality without writing a single line of code. So, below is my no code solution.

My Solution

1. Create one custom entity say “Unfulfilled Orders”

2. Create new N:1 relationship with Order entity (A business required field)

3. Drag the mandatory order lookup control on a form

4. Create one workflow on this custom entity (created in step 1)

In workflow, first check the status of related order whether it is fulfilled or not.

If it fulfilled then only change its status to “New” as described in below screen shot.

image

5. On Administration tab, select the check box at the bottom of the window i.e.

“Automatically delete completed workflow jobs”

6. Change sitemap to place this custom entity at Settings – underneath Business tab.

7. Change the specific security role(s) which should have an access on the above custom entity.

8. Publish all customization changes.

9. Do not forget to activate the workflow.

And that’s it.

Here, I am done with my solution. Users who have permission on this entity can access it from Settings – Business area. I have configured the workflow to be triggered on two events, on creation of a new record or on change of related order record (change of orderid via lookup control) in edit mode. In both cases the above workflow will trigger and change the status of the related order to “New”. Moreover, it is a quite scalable solution; system administrator can allow/disallow this functionality to specific security role(s).

Please feel free to update this post with your no code solutions to reopen fulfilled order records, if any.

Saturday, 9 February 2013

Dynamics CRM 2011 – Mapping of fields from Opportunity Products to Invoice Products

Recently, one of my customers would like to map couple of common custom attributes during execution of entire sales cycle. They are using the out of the box Dynamics CRM sales process. They have these attributes on Opportunity Product entity and want the same values to be auto populated with rest of the sales cycle. Like, when you create Quote record with Quote Products from an opportunity, the same custom attributes should be filled automatically for Quote Products. Likewise, the custom attributes should be populated when you create an Order with Order Products from a Quote and Invoice with Invoice Products from an Order.

Out of the box you cannot find such mappings on these relationships. So, to achieve this requirement, you can use below trick to generate the hidden mappings URLs.

On your development server/machine you just need to execute below query in SQL Management Studio to find out relationship GUID id for Opportunity Product and Quote Product entities.

SELECT    EntityMapId 
FROM      EntityMapBase 
WHERE     TargetEntityName='quotedetail' AND SourceEntityName='opportunityproduct' 


Use the above GUID in below URL and also change the organization name.

http://localhost:5555/[ORG_Name]/Tools/SystemCustomization/Relationships/Mappings/mappingList.aspx?mappingId=[Your_GUID]

Now, launch internet explorer and paste this URL at address bar. As displayed in below screenshot, you could see the list of all available mappings of the above two entities.

image

Click on New button to open below field mapping popup. Here, you are free to do your mappings.

image

In the same fashion, find out the mapping GUIDs for Quote Product to Order Product and Order Product to Invoice Product. Prepare their URLs as explained above and complete the attribute mappings.

Finally, add these entities to your unmanaged solution on your development organization. Export it as a managed solution and import the same on QA and Production environments. The same mappings should be applied to those organizations too. Moreover, the same managed solution can also be imported to CRM 2011 online or partner hosted.

I hope this will be helpful.

Reference:

http://crmconsultancy.wordpress.com/tailoring-the-product-selection-for-opportunities-and-quotes-in-dynamics-crm/productcataloguemapping-mscrm-fields-from-opportunity-product-to-quote-product/

Saturday, 2 February 2013

Dynamics CRM 2011 - LookupSet Function in SSRS reports

 

Syntax

LookupSet(source_expression, destination_expression, result_expression, dataset)

LookupSet is generally used to retrieve a set of values from the specified dataset for a name/value pair where there is a 1-to-many relationship. For example, for a customer identifier in a table, you can use LookupSet to retrieve all the associated phone numbers for that customer from a dataset that is not bound to the data region.

The above is the description specified for use of LookupSet function. Yesterday, while creating a report I used the LookupSet function and overlooked the highlighted text. I used the LookupSet in a column expression within the tablix. The Dataset assigned to tablix was “DataSet2”.

image


In the LookupSet also I specified the same DataSet i.e. DataSet2 . While executing the query on DataSet, rows were fetched as required.


image


AS viewed above 8 distinct names could be viewed. But when running the report one row was not displayed in tablix but the distinct count i.e. 8 was correctly calculated on very first row of that column.

image

After spending few hours I found that the culprit was LookupSet function which was used in an expression of a column on same tablix . Both tablix and Lookupset function were using the same Dataset i.e. DataSet2.

image

According to the function description, the dataset that is not bound to the data region should be used whereas we were using the same dataset that was used for binding in the data region.

So, the solution is to create another dataset with fields that you want to Lookup. In the LookupSet function specify the newly created DataSet.

image

For me this fixed the weird behavior in displaying rows and the final results are displayed in below screen shot.


image