Tuesday, July 17, 2012

My First NuGet Package

It's done. And it was quite easy.

There are enough great posts about creating this packages and the complete publishing process. So here are just some links i have used.



The most of them explain the creation via the nuget.exe command line application. There is also a nice UI available.



Cheers,
Markus

Project - PluginQuickDeploy Update 0.9.0.2

I have created a new version of pqd with minor changes.
Most important part is the NuGet Package.

Project Page: 
http://pqd.codeplex.com/ 

NuGet Package: 
https://nuget.org/packages/PluginQuickDeploy

NuGet Command: 
PM> Install-Package PluginQuickDeploy

Cheers, Markus

Wednesday, July 11, 2012

CRM 2011 - Accessing and filtering custom/crm WCF Data Service (oData) from sandboxed Plugin

As described in some MSDN-Forums and by Eric Pool, Quering data against the context directly via Linq in sandboxed plugins is not possible. You can retrieve the whole DataSet, but filtering is not possible.

If you need to access and filtering your results from an oData endpoint (also custom ones), you can use the following syntax.

Example OrganizationDataService (with FirstOrDefault):
//Define the Request URI
Guid accountId = new Guid("66BD3ABE-D2CA-E111-9E1F-000C29BDAB09");
string serviceAddress = @"http://crm:5555/DEV/XRMServices/2011/OrganizationData.svc/";
string accountQueryByPrimaryKey = string.Format("AccountSet(guid'{0}')", accountId.ToString());
Uri svcUri = new Uri(serviceAddress);
Uri accountUri = new Uri(string.Format("{0}{1}", serviceAddress, accountQueryByPrimaryKey));
 
//Create context and credentials ('My' is the name of the CRM organization, these classes are created when you add a service reference to CRM DataService endpoint)
CrmService.MyContext context = new CrmService.MyContext(svcUri);
context.Credentials = new System.Net.NetworkCredential("username""password""domain");
 
//Retrieve data
Account retrievedAccount = context.Execute<Account>(accountUri).FirstOrDefault();


Example Custom Service (with Enumeration):
// Define the Request URI
Uri svcUri = new Uri(@"http://crm:8888/MyDataService/CustomDataService.svc/");
Uri uriAccounts = new Uri(string.Format("{0}{1}", svcUri, "ACCOUNT(3)"));
 
// Create the context
DataServiceContext context = new DataServiceContext(svcUri)

// Enumerate over the query result.
StringBuilder sb = new StringBuilder();
foreach (ACCOUNT account in context.Execute<ACCOUNT>(uriAccounts)) { sb.AppendLine("Name: " + account.name); }

The trick is to use the oData (URI) for Filtering and to interprete just the results.

You can find the MSDN description here.

Friday, July 6, 2012

Project - PluginQuickDeploy

Today i have created my first project on Codeplex. Very nice page, the creation process was really easy and straight forward.

This small project was on my backlog for a very long time.

"PluginQuickDeploy" reduces the development time of Microsoft CRM Plugins, because the deployment to the test system is done by one click or directly in the build process (build events).

You can find the project here.