Sunday, December 7, 2014

CRM 2015 SDK - Get organization details from Organization service

A few weeks ago, I was working on a plug-in for a Microsoft Dynamic CRM 2013 project and wanted to add organization-specific logic to it. In CRM version 2013, Microsoft did not provide a way to get organization details using the Organization.svc service endpoint but in CRM 2015 Microsoft added this capability with RetrieveCurrentOrganizationRequest and related classes. This allows for more adaptable code in plug-ins, workflow activities and other applications. For example, you might want to call a different Web API endpoint from a plug-in depending on whether the plug-in is running in production vs. running in a development sandbox instance.

Monday, March 24, 2014

Dynamics CRM Wiki

I'm creating kind of a CRM quick reference here: At Altriva, I work on a wide range of CRM projects, so having a quick guide to CRM functionality (customizations, development, deployment, maintenance, etc.) will be handy. I hope you find it useful as well.

Sunday, March 16, 2014

A "What If" experiment... Evaluate Excel formulas in Dynamics CRM Plug-ins

What if you could combine an Excel engine (one that can evaluate formulas) with Dynamics CRM in a plug-in...

Well, it turns out that you can.

I've only worked on this for a couple of hours this morning (the family is awake now) but here's what I've been able to do so far...
  1. Download and install SmartXLS, a .NET Excel-compatible library.
  2. Create a simple plug-in that calls the SmartXLS library to generate a random number (using the RAND formula function; SmartXLS supports most Excel functions). The plug-in simply updates the accountnumber field for a new Account with the random value.
  3. Use ILMerge to merge SmartXLS's XL.DLL with my plug-in assembly. This allows you to register the plug-in and the SmartXLS functionality in a single assembly so there's no need to GAC anything... and this should allow it to work with CRM Online.
  4. Register a plug-in step for Create message for the account entity, pre-operation, synchronous.
  5. Create an account record. Voila! We have a random account number. (Not terribly useful, but you get the idea.)
What's exciting about this is that it's possible to tap into Excel (well, most of it) to execute hundreds of formulas and functions. If the plug-in could simply replace values in a pre-defined workbook, then theoretically a single plug-in could process formulas for any CRM entity.

Here's the part of the plug-in code that creates a worksheet, sets a formula, gets the random number and sets the accountnumber field for the new Account in CRM...

WorkBook wkbook = new WorkBook();
wkbook.NumSheets = 1;
wkbook.Sheet = 0;
wkbook.setFormula(0, 0, "RAND()");
randValue = wkbook.getNumber(0, 0);
entity["accountnumber"] = randValue.ToString();

Here's the plug-in registration details:

And our Account record with the randomly generated account number:

Where to take this next...?  Here are some ideas:
  • Since SmartXLS can read in XLS files, it's possible to pre-defined formulas in Excel and somehow feed the XLS into the plug-in (perhaps as an attachment to a custom entity). The plug-in will replace value in the worksheet, recalc, and update CRM with the results.
  • If a formula needs data from other related entities... that's trickier but certainly possible. A FetchXml statement on a worksheet could define the data to get from CRM. Once the data is retrieved, a formula can get whatever value is needed from the resulting data (e.g., min, max, average, etc.).
  • A formula updates values brought in from a FetchXml query. The plug-in updates the CRM records with the resulting values. Think bulk-update with the power of Excel formulas.
Of course, I know that there are off the shelf solutions like N52 Formula Manager, but wouldn't it be more fun to build the same functionality yourself?  (I didn't say it would be cheaper or as robust, at least not at first, but definitely more fun.)

Well, that concludes my What If experiment this morning. I hope it inspires you to harness the Dynamics CRM platform to do some creative things to solve business needs... or just pass some time while the family sleeps.



Tuesday, March 4, 2014

Time flies when you're having fun

Hey there fellow Dynamics CRM enthusiast, thanks for stopping by. It's been a while since I've posted but here's what I've been up to on various projects here at Altriva:

Siebel to CRM 2011 Data Migration
  • Early last year, we helped a client migrate their data (and configuration/functionality) from a Siebel 2000 system to Dynamics CRM 2011 (on-premises). Given the dozens of migrations I've done in the past, I was up for this challenge and am proud to say that it went very well.
  • Our custom data migration application migrated 6.5 million rows across 42 entities. This includes 1.2 million attachments (into SharePoint, encrypted).
  • The application scales to an unlimited number of loading machines and instances. On go-live weekend, we used 6 VMs and 3 app instances on each to get all of the data in on time.
  • The application is driven by migration steps in SQL Server. It handled the entire migration with very few hiccups. When there were hiccups (network glitches leading to loss of connectivity) the application was able to wait and continue where it left off... and that allowed me to even get some sleep during the weekend.
Correspondence Generation in Dynamics CRM using SSRS
  • One Altriva client needed to generate Word and PDF correspondence (e-mails, letters, faxes, government forms) from CRM, both on-demand and after an event occurred in CRM (e.g., an appointment was scheduled or canceled). The correspondence needed to include data across 5 to 10 entities, so the usual mail merge and template features in CRM would not suffice. Our client had in-house experience with SQL Server Reporting Services so we built the custom correspondence around SSRS and a custom WCF service. The design in a nutshell:
    • Create custom Correspondence Template entity in CRM. This stores the path to the SSRS report and sets various parameters/options for each piece of correspondence, such as the type of document to produce, where to attach the generated document, etc.
    • Create custom Correspondence Request entity in CRM. A user or an automated process creates a Correspondence Request record. This entity data (correspondence template, "regarding" entities, etc.) is sent to a custom WCF application via plug-in.
    • The custom WCF application calls SSRS via web services to generate the Word or PDF document. It then proceeds to display the document in Microsoft Word or Adobe Acrobat or it creates an e-mail record in CRM and sends the e-mail.
  • All in all, SSRS worked out well for correspondence. We did find the need to purchase a license to the Aspose PDF product in order to generate the government forms -- the formatting for those was too much for SSRS to handle.
Several CRM 4.0 and 2011 Upgrades to 2013
  • As you can imagine, Microsoft partners like Altriva were (are) kept very busy helping Dynamics CRM 4.0 and 2011 clients upgrade to CRM 2013. We've helped clients in a wide range of industries upgrade their CRM and it's been fun helping to implement the new features depending on the business's need. We now have iPads and other tablets here at Altriva to test the new tablet functionality in Dynamics CRM 2013. And we have Hyper-V and VirtualBox VMs configured to try out server-side sync with Exchange, Azure and SharePoint integration, and all of the other great new features Microsoft has added to the product.
Those are just some of the projects I've been working on. Outside of those, I'm scheduled to take the CRM 2013 exams (to upgrade my completed CRM 2011 exams). Also, several of us at Altriva are registered for the charity event "The Big Climb" to benefit The Leukemia & Lymphoma Society.

Catch you later,

Tim Dutcher