Thursday, May 30, 2013

CRM2011 and GeoFlow

Two weeks ago, I have attended a CRM infrastructure course at CRM enterprise academy. During this course, we were shown a demo of a new Excel 2013 add-in named GeoFlow.  It is a BI tool that can turn the thousands of rows of  data with some spatial information into interactive 3D tour on Bing Maps. It is still in beta and can be downloaded from here.

The example we were shown was using the leads data from CRM2011 with the city and lead source information. It was amazing. I don’t have a lot of CRM data right now but I managed to get some rental bond data for suburbs in NSW Australia. I tried to compare the rental bond data for different suburbs for the month of march in 2007, 2010 and 2013. Here is the screen shot.


This is how it looks like in real time.  You can do a whole lot of things with GeoFlow . For example adding multiple scenes, zoom in or out of the map, adding annotations, choosing chart types and selecting an item on the map to get more information etc.



Have a look at the article from Microsoft Research.

Monday, May 6, 2013

How to use ExecuteMultipleRequest with ServiceContext and Linq

Most of  CRM2011 developers must have used the service context and linq before. I have also blogged about it in the past in one of my plug-in tutorial. CRM rollup 12 has introduced a new method “ExecuteMultipleRequest”. This method receives a collection of requests (same or different type of requests). The method return the response collection. Here is the link to sample code from Microsoft.

I was playing around this method and came across some code from my favourite CRM expert “David Berry”. I tried to use his code with service context and here is the result. I have hard coded few things in my sample but you can change it as required.

The following code is retrieving all the contacts where parent customer id is C6CB814A-BA75-E011-8720-00155DA5304E and updating their phone number.

var ServiceContext = new OrganizationServiceContext(service);
Guid accountid = new Guid("C6CB814A-BA75-E011-8720-00155DA5304E");

// Create an ExecuteMultipleRequest object.
ExecuteMultipleRequest requestWithResults = new ExecuteMultipleRequest()
    // Assign settings that define execution behavior: continue on error, don't return responses. 
    Settings = new ExecuteMultipleSettings()
        ContinueOnError = false,
        ReturnResponses = false
    // Create an empty organization request collection.
    Requests = new OrganizationRequestCollection()
requestWithResults.Requests.AddRange(from c in ServiceContext.CreateQuery("contact")
                                    where c["parentcustomerid"].Equals(accountid)
                                    select new UpdateRequest()
                                        Target = new Entity("contact")
                                            Id = c.Id,
                                            Attributes = { new KeyValuePair<string,object>("telephone1", "+61402234212") }

// Excute the requests
ExecuteMultipleResponse Response = (ExecuteMultipleResponse)service.Execute(requestWithResults);

If you are using any other entity collection then you can change ServiceContext.CreateQuery("contact") with that.

I have highlighted the following lines
ContinueOnError = false
ReturnResponses = false

These lines are self explanatory. The first line means that continue on error and the second line means that do not return the response. 
Please check the code from Microsoft for complete/detailed explanation.