Tuesday, March 13, 2012

N:N association

When we have to associate the records we normally use AssociateRequest but while associating campaign with campaign related items such as Campaign, Marketing List, Product, or Salesliterature it doesn’t work.

For achieving this we have special Message made for Campaign called AddItemCampaignRequest.
Below we have provided the code that will associate the Campaign with Campaign Items.

//Add Item to Campaign
AddItemCampaignRequest req = new AddItemCampaignRequest();

// Specify the Campaign Id
req.CampaignId = new Guid(CampaignId)

// Specify the Logical name of the entity to which we want the Campaign to be associated
req.EntityName = entity.LogicalName;

// Specify the Id of the entity to which we want Campaign to be associated
req.EntityId = new Guid(EntityId)

// Execute the request
AddItemCampaignResponse resp = (AddItemCampaignResponse)_service.Execute(req);

We can associate Campaign, Marketing List, Product,
or Salesliterature with the Campaign through the AddItemCampaignRequest message.

To use this message, pass an instance of the AddItemCampaignRequest class as the request parameter in the Execute method. To perform this action, the caller must have access rights on the campaign entity instance.

Same we can associate the Campaign Activities with the Marketing Lists through the AddItemCampaignActivityRequest as given in the below code.

// Create the request object.
AddItemCampaignActivityRequest add = new AddItemCampaignActivityRequest();

// Set the properties of the request object.
add.CampaignActivityId = new Guid(CampaignActivityId);

// Specify the List Id to which we want Campaign Activity to be associated
add.ItemId = new Guid(listId);

// Specify the Logical name of the entity to which we want the Campaign Activity to be associated
add.EntityName = EntityName.list;

// Execute the request.
AddItemCampaignActivityResponse added = (AddItemCampaignActivityResponse) service.Execute(add);

The Marketing List being added must have already been added to the campaign otherwise error will be thrown and Marketing List will not be associated with Campaign Activities.

Hope this helps!!!

Monday, March 5, 2012

Experiences from the MVP Summit!

Well, this was one travel that I had not planned for. But today I am happy that I did not skip it. This was my first MVP summit after being awarded MVP in January this year and it was an enriching experience.

I was one of the 41 CRM MVPeeps that were present at the summit and I was the only one from India in the CRM Group. The group had representation from most parts of the world and it was great to see the reach and adoption of CRM across the world.

There were many sessions revolving in and around CRM and unfortunately not much can be shared here to due to the NDA. All that can be said though is CRM is heading the right direction and we are in safe hands :)

It was a pleasure to hear the product team speak about the future of the product and thier vision for the product. It was good to know we could share our concerns and they would be addressed and that we were not just there to hear them talk but the product team was listening to us as well and that as MVP we were really a valuable community for them.

Amy did a really great job at organizing the sessions and many thanks to her to make sure we are all well looked after :)

Besides the sessions which were by the way not all work but actually a lot of fun, there were also other parties organized in the evenings. The closing ceremony was held at Centurylink fields. There was a fireworks show and we had a chance at the ball on the fields.

A very big thanks to all MVP's to make us first timers feel welcome. Looking forward to Convergence that starts 18th March and I expect that to be an equally enriching experience and I really look forward to meeting all my friends back again!



Tuesday, February 28, 2012

Issue with plug-in in CRM 2011

We had a requirement to do some calculation and update self record of custom entity. We have created a plug-in and registered it on post operation of update event. The code was reading the post image, updating some fields and updating the same.

The plug-in was working fine for single record. But when two records are saved simultaneously, the plug-in was giving below errors randomly.


1. "ValidateOpen - Encountered disposed CrmDbConnection when it should not be disposed"
2. "You cannot create a SqlExecutionContext from another SqlExecutionContext on which OnBeginRequest has not been called"
3. " System.InvalidOperationException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #58919D7E"
4. "System.NullReferenceException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #1638FFA8"

When we checked in the Event viewer then we got that whatever error we get from CRM the Event viewer shows "System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first." error.

After searching on net we found that CRM does not re-initialize the plug-in object again, it uses the same object. In the plug-in, ignore to use class level variables. We had created service object at class level so it was using the same service object for retrieving and updating.

Also we were reading post image and updating the post image as it is. This was also creating a problem. Please create a new object of Entity and then set only those fields which you want to update. Then update the record.

Sometimes this plug-in takes too much time as it was doing so many calculation. We were getting the "Query execution time of 30.1 seconds exceeded the threshold of 10 seconds. Thread: 4; Database: inogic_MSCRM " error when plug-in takes time. To resolve this, please add below keys in the registry on CRM server.
1) HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM\OLEDBTimeout
a. In seconds
b. The OLEDBTimeout value controls the SQL time-out value that is used for a single SQL query
c. Set it to 60 seconds


2) HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM\ExtendedTimeout
a. In milliseconds
b. The ExtendedTimeout value controls the ASP.NET time-out value
c. Set it to 1,000,000


3) HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM\NormalTimeout
a. In milliseconds
b. Specifies the SOAP call timeout for most operations
c. Set it to 300,000

Hope this helps!!

Wednesday, February 22, 2012

How to debug XAML bindings in Silverlight 5

Microsoft has released Silverlight 5 !! A new feature is available in Silverlight 5 and it is XAML Data Binding debugging. For any data driven application with declarative data binding, within XAML, this brand new feature is the significant in various ways.

Prerequisites:


Silverlight 5 toolkit
Silverlight 5 Developer Runtime
Visual Studio 2010 SP1

The example demonstrated here implements basic XAML data binding. Below we have specified both the scenario when binding is correct and incorrect.

In below example we have given a simple binding for DataGrid.

When Binding is Correct:




Now you can apply a breakpoint to the binding syntax. Once the break point is applied, it hits the breakpoint whenever push and pull is triggered for that control. The below image shows the breakpoint applied within XAML


The XAML editor will not allow you to set breakpoint anywhere else other than Binding syntax.
Once Breakpoint is set, start debugging and wait for the compiler to hit the breakpoint.


You can find the debug information from Local tab.


The information shows up a BindingState object holding complete binding context information of the control. As in the above image, the BindingState value is UpdatingTarget so this way it shows that the binding is pushing data to control.

Going through the debugging information, it shows the complete picture on the nature of data and binding


Now another thing to know is, on TwoWay binding scenario once you change the data, The breakpoint again gets a hit as the binding source is getting updated. And the debug information shows the Binding state as Updating Source status. The breakpoint again gets a hit as the binding source is getting updated. And the debug information shows the Binding state as Updating Source status.


When Binding is Incorrect:

When binding is incorrect you will get the error while debugging the binding.


This will help you to find the incorrect bindings in your XAML.
Hope this helps you to get acquainted with the new feature of Silverlight 5

Wednesday, February 8, 2012

Features to be included in the Q2 2012 service update.

Some very exciting features have been announced that would be made available in the Q2 2012 service update. Here we discuss a few of them

Cross Browser Support
CRM had been restricted till date to be accessible through Internet Explorer only. However, with this release the user would now have the choice of browser. They can choose from IE v7+, Firefox v6+ and Chrome v13+. Safari v5.1.1+ as a browser would be supported on Apple Mac OS-X and iOS 5.x.

CRM Anywhere:
Besides giving a choice of browser, it will also provide mobile options as a part of the new cloud based mobile CRM service called Microsoft Dynamics CRM Mobile. This would however be a paid service and to begin with only be available in 24 markets (India not included) Native apps would be available for the following devices

Windows Phone v7.5+
Apple iPhone 3GS+ iOS 5+
Google Android v2.2+
RIM Blackberry v6.x +
Apple iPad/iPad2 iOS 5+

Note: The initial release of Microsoft Dynamics CRM Mobile for Windows Phone will not support offline data

Dashboard view would also be available on the mobile. Check this out…



Industry Solution Templates:
Industry templates would be made available for the following

Life Annuity Insurance Sales
Non-Profit
Health Plan Sales
Wealth Management

Custom Workflow Activities in CRM Online:
It was not possible to create custom workflow activities in CRM Online and solutions had to be re-designed around Plugins most times. It would now finally be possible to create Custom Workflow Activities in CRM Online as well.

Rapid View Forms:
It would now be possible to design Rapid View Forms that would be read-only forms. This would help the forms to be loaded quicker when the purpose of accessing the data is only to read the information and not make any edits. It would be possible to convert the read-only form to edit mode at the click of a button.

It would be possible for the user to decide if they wanted their forms to be loaded by default in the read-only mode or edit mode.

To read in detail about the features to be introduced check out the
release preview guide