Sunday, July 17, 2011

Microsoft CRM Email Router 2011

Yesterday I installed the new email router for MS CRM 2011 and I gathered some resources that might be useful:
- The email router can be downloaded from http://www.microsoft.com/download/en/details.aspx?id=20548
- Microsoft CRM 2011 Email Router installation guide: http://www.microsoft.com/download/en/details.aspx?id=18991
I configured the email router to work with Microsoft BPOS SMTP and Microsoft CRM 2011 Online version. Here is how it's done:
1. Go to MS CRM user records and change the "Email Access Type – Outgoing" to "Email Router".
2. Open the email router and create a profile for outgoing messages. I decided to use BPOS SMPT service so in the email server type is chose "SMTP" and the authentication type should be "Clear Text".
3. Mark the "Use SSL" box
4. The location of the profile should be "smtp.mail.microsoftonline.com"
5. Enter a user name (email) and password of one of the admin accounts on your Microsoft Online Email service.
6. Change the network port to 587
7. Save the profile
8. Create a deployment record by choosing to connect to Microsoft Crm online and place your unique organization name in the Microsoft CRM server location box (unique name can be found under Settings -> Customization-> Developer resources)
9. Publish changes

Tuesday, June 28, 2011

MS CRM 2011 Retrieve Limit

While working with MS CRM 2011 version I have discovered that if you are rtying to execute a query and retrieve more then 5000 records without specifying PageInfo parameters, you will only get the first 5000 records.
Here is how to approach this:

QueryExpression query = new QueryExpression("lead");
query.ColumnSet.AddColumns(leadColumnSet);
int pageNumber = 1;
RetrieveMultipleRequest multiRequest;
RetrieveMultipleResponse multiResponse;
do
{
query.PageInfo.Count = 5000;
query.PageInfo.PagingCookie = (pageNumber == 1) ? null : multiResponse.EntityCollection.PagingCookie;
query.PageInfo.PageNumber = pageNumber++;

multiRequest = new RetrieveMultipleRequest();
multiRequest.Query = query;
multiResponse = (RetrieveMultipleResponse)ServiceProxy.Execute(multiRequest);
leads.Entities.AddRange(multiResponse.EntityCollection.Entities);
} while (multiResponse.EntityCollection.MoreRecords);

Sunday, June 26, 2011

IFD for MS CRM 2011

Solutions.

MS CRM 2011 introduced a new concept called Solutions. For those of you who used MS CRM 4.0, solutions are the new way to transfer customizations (and other staff) between deployments. In version 4.0, we could only transfer entities, fields, workflows, security roles, isv.config and site map definitions. The 2011 version includes all of these capabilities and some more powerful new capabilities. The exported solution file is actually a zip file containing several components:
1)      The customizations file: this file is very similar to the customizations file of version 4.0, only that, now, we do not have isv.config. We now have Ribbon!
2)      Plugins: the zip file will also contain the plugin dll files which were registered to the deployment you are exporting from. The package also contains all the steps that were registered to these plugins so you don’t need to re-resister them on the target deployment.
3)      Reports: all custom or native reports you have included in the solution will be exported
4)      Security: field level security or other security settings are also included
5)      Dashboards…
6)      Web Resources: images, js files, html files or any other resource included in the solution
So, for a developer using the SDK guidelines to develop a supported solution built on top of MS CRM v2011, it is now extremely easy to package and distribute the customizations and custom developments made to the platform.
There is one more important thing to realize with solutions – managed vs. unmanaged solution files. It is easy to understand what an unmanaged solution is. It is very similar to the concept we had in v4.0, which is, all changes are permanent.  If you import an unmanaged solution to a new deployment, deleting the solution WILL NOT delete the components it contained from your deployment. The only way to completely remove the components will be to delete all of them manually. The changes made by the unmanaged solution are deeply burned into the "Default Solution".
A managed solution is a different story. You define a solution to be managed when you export it. Once a solution has been set as managed, it is considered as a "closed box" and something which is very similar to the way we treat software installation. When you install a software product, you do not have access to the code and cannot change the screens. If you don’t want to use the product, you simply uninstall it. Managed solution is the same thing. You treat it as a sealed product ready for installation on top of the MS CRM platform. In any case you will want to remove it, deleting the solution will remove ALL of the components that were inside the solution and ALL the data they hold.

Using the Plugin Registration Tool for MS CRM 2011

I just found a great article for using the new plugin registration tool for MS CRM 2011 version. Did you know that plugins are now supported also in the Online version?? Yey!!!
http://msdn.microsoft.com/en-us/library/hh237515.aspx

Update Money Field Using REST API

I saw few questions about this subject as it is not included in the SDK examples and not very trivial for REST beginners. The key thing to understand is that the MS CRM money field is an object. So not like string or integer, you need to correctly update the object value.
For our example, lets assume we have a campaign record and we want to update the "OtherCost" field. Here is how it is done:


// update the parent campaign with the total value
var changes = { "OtherCost": { "Value": total.toFixed(2)} };

var updateReq = new XMLHttpRequest();
var target = context.getServerUrl() + "/XRMServices/2011/OrganizationData.svc/CampaignSet(guid'" + campaignId + "')";
updateReq.open("POST", target, true);
updateReq.setRequestHeader("Accept", "application/json");
updateReq.setRequestHeader("Content-Type", "application/json; charset=utf-8");
updateReq.setRequestHeader("X-HTTP-Method", "MERGE");

updateReq.onreadystatechange = function () {
if (updateReq.readyState == 4 /* complete */) {
    if (updateReq.status == 204 || updateReq.status == 1223) {
       // success
    }
    else
    {
       //OMG an error occured! Do something!
    }
}


};
updateReq.send(JSON.stringify(changes));