Dynamics CRM Plugins in F#

Posted by on April 24, 2014 in   |  Microsoft Dynamics CRM,   |  Microsoft Dynamics CRM 2011,   |  Microsoft Dynamics CRM 2013  |  commentsComments (0)

Today’s guest blogger is John Trujillo, a Developer at Sonoma Partners.

Every so often I promise myself I will spend more time learning the F# programming language. For one reason or another, I rarely do. Yet, whenever I think back to my favorite college programming courses, the courses in non-imperative languages (like Scheme or ML) always come to mind. So it should only make sense for me to learn F#, especially since it is fully supported in .NET. I recently decided to make good on my promise, this time attempting to apply what I have learned to a Microsoft Dynamics CRM plugin.

Even if you don’t know much about F# but are familiar with .NET and Dynamics CRM development, none of the following code snippets will be a complete mystery. However, you may want to spend some time getting to know the language. I won’t go into great detail regarding syntax. Thus far I have found it to be a fun language to code in, and I recommend you take a look for yourself. The F# community is very active and helpful. In my case I followed the “Why use F#?” series at F# for Fun and Profit, but you should also visit The F# Software Foundation. There is a huge selection of books available for purchase. Compilers are freely available on all major OSes. You can code on the browser at Try F#. Likewise, if you are reading this post, you may already be developing for CRM in Visual Studio, and so F# projects are already available to you. Visual Studio also provides a REPL interactive window to try out snippets as you develop your project. You can also create F# programs in LINQPad.

On to the business of creating a plugin. There are only a handful of steps to get started. The biggest hurdle for me was getting my project set up to play nicely with CRM and the Registration Tool, which I will point out shortly.

  • Add a new F# Library Project. This type of project is available in Visual Studio out of the box.clip_image002
  • Grab the latest Dynamics CRM 2013 SDK core assemblies from NuGet.
  • Delete the default .fs and .fsx files in the project and add a new F# file for your plugin. In my example, I named it AutoNamePlugin.fs. Here is what the initial plugin code looks like, which is the minimum necessary to validate registration and execution:
// AutoNamePlugin.fs
namespace Sandbox2013.Crm.Plugins.Functional

open Microsoft.Xrm.Sdk

type AutoNamePlugin(configuration) =
    interface IPlugin with
        member this.Execute serviceProvider = 
            raise (new InvalidPluginExecutionException("F# plugin registered"))
 
image 
 
  • Build the project, register the assembly, and add your plugin steps as you normally would in C#. This was the trickiest part to set up correctly. I ran into a few roadblocks preventing me from registering and testing the plugin. You will likely encounter the same issues, so here are my solutions:
    • Sign the assembly. The project properties UI doesn’t have a Signing tab, so you will have to create a key pair file manually.
      • Enter in the command prompt:

c:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\sn.exe -k <KeyName>.snk

      • Add the .snk to the project post-build event. (I copied a post-build script from a C# plugin project and just updated file/dll names appropriately.)
    • Don’t define the plugin type inside of a module. It’s not shown in the snippet above, but I originally defined the plugin (type AutoNamePlugin) within a module. The Plugin Registration tool would not register it, even though I could see and select it in the tree view in the Update Assembly dialog. I was able to add the assembly after I pulled it out of the module. Namespaces are fine.

image

    • Add FSharp.Core.dll to the merged assembly. Once my assembly was successfully updated and my first Opportunity create step added, I tried to get my exception to fire when I saved a new Opportunity. However, the popup error was “Unexpected Error” and not the business logic error message I set up in the plugin. When I removed the exception, the error still occurred. I jumped onto the CRM server to look at the event logs. It turns out I needed to merge in the Fsharp.Core assembly as well. Add that as part of the post-build event script, which will resolve the error.
  • Once you have verified that your plugin is correctly set up, replace the exception with your own logic.

image

image

And there you have it, now you can enjoy creating plugins in a functional language!

For the curious, I uploaded my first full plugin implementation, which you can get here.

CRM 2011 UR12+ and CRM 2013 Fetch Aggregate Bug

Posted by on March 26, 2014 in   |  Microsoft Dynamics CRM,   |  Microsoft Dynamics CRM 2011,   |  Microsoft Dynamics CRM 2013  |  commentsComments (0)

Recently we were upgrading the look and feel of some custom CRM 2011 web resources to match the styles in CRM 2013 and my colleague found an interesting Fetch XML aggregate bug.  A simple fetch aggregate query, like below, will work just fine in CRM 2011 UR11 and below.  When you run the same query in CRM 2011 UR12+ or CRM 2013, you will get “An unexpected error occurred.”. 

<fetch mapping="logical" aggregate="true" version="1.0">
        <entity name="account">
                <attribute groupby="true" alias="accountid" name="accountid” />
                <attribute name="name" aggregate="countcolumn" alias="accountCount" />
        </entity>
</fetch>

After some troubleshooting, my colleague determined that the accountid attribute was the culprit.  He changed the alias to something other than ‘accountid’, like below, and it ran successfully.

<fetch mapping="logical" aggregate="true" version="1.0">
        <entity name="account">
                <attribute groupby="true" alias="accountKey" name="accountid” />
                <attribute name="name" aggregate="countcolumn" alias="accountCount" />
        </entity>
</fetch>

We logged this bug with Microsoft which will hopefully be resolved in the next UR as it unexpectedly breaks previously supported code.

Convergence 2014 Recap – Part 1

Posted by on March 10, 2014 in   |  Microsoft Convergence,   |  Microsoft Dynamics CRM,   |  Microsoft Dynamics CRM 2011,   |  Microsoft Dynamics CRM 2013  |  commentsComments (0)

The Convergence 2014 Keynote last week kicked off with the Dynamics Roadmap for this year.  There are two big updates set for Dynamics CRM, one being a Spring Update that should be right around the corner and then an Autumn Update later this year.  Wayne Morris, CVP of Microsoft, talked about the previous announcements of Marketing, Custom Service, and Social Listening functionality as well as a new addition for the Spring Update called the Unified Service Desk.  The Unified Service Desk is a desktop application meant for call center users to help with case management which is shown in more detail below.

image

Kirill Tatarinov later came out and discussed several key points on how Microsoft Dynamics can deliver amazing experiences with the help of the recent acquisitions such as MarketingPilot, NetBreeze, and Parature. 

 

Market Smarter

Wayne Morris came back out to demo the new Microsoft Dynamics Marketing functionality that will be coming this Spring and how it helps him market smarter. 

The landing page below shows a nice quick view into your marketing budget and how the budget is being utilized.

image

Similar to CRM 2013, there is a card-based navigation at the top but clicking a card will expand to show child navigation links within that area.  This is very slick and we’re hoping that Microsoft will bring this same navigation into CRM 2013 as currently it is very hard to navigate if you have a lot of entities.

Within Dynamics Marketing, marketers can manage their assets & media which acts as a specialized SharePoint for marketers.  This includes file upload, approvals, and version control.

image

Next Wayne shows a campaign workflow where you can easily drag and drop campaign activities to execute.

image

He then adds a new Social Media Messages campaign activity that will send Twitter, Facebook, and/or LinkedIn messages at scheduled times.

image

Users can then view the performance of the campaigns using several different charts and filters (e.g., by campaign and by channel).  Kirill mentions that the graphs are built using Excel Web Apps.

image 

This all looks very slick and will definitely empower marketers.  Currently these are separate applications but there is a connector that integrates data between Dynamics Marketing and CRM (e.g., Leads, Contacts, Campaigns).  The question remains how much will this integration be expanded in the future versus kept in separate applications.

 

Sell Effectively

image

Kirill brought out Judson Althoff, President of Microsoft North America, to show how he uses Microsoft products to sell effectively.  He pulls up his custom built dashboard that uses Live Tiles to pull in sales data real-time from Microsoft Dynamics.  The dashboard is pulling in information from 20 different systems.

image

Pipeline chart pulling in data from CRM 2013:

image

Using Windows 8.1 to easily share the Pipeline data and attach it to an email:

image

Drilling into a record from the Windows 8.1 app automatically snaps in CRM 2013:

image

Judson shows the app being ran from his Windows Phone as well:

image

This was a good segment that shows the competitive advantage that Microsoft has over competitors by being able to utilize a suite of Microsoft products to empower your users.  Unfortunately the app seems to be completely custom built by Microsoft for their business but it does a good job of showing what is possible.  If you are interested in a custom app for your business, take a Mobility Test Drive with us where we will have our UX Architect do a field ride along with one of your users and come back with some high and low fidelity mockups as well as a working prototype.

 

Care Everywhere

image

Kirill discussed the importance of customer care and the ability for customers to self-serve.  Microsoft fulfills this requirement with the functionality that the newly acquired Parature brings to the table.  Fred Studer, GM of Microsoft Product Marketing, comes to the stage to show off a Parature portal example of BusinessUSA.gov.  BusinessUSA.gov uses Parature to categorize their information and provide the ability to search across that content.  Using Parature, BusinessUSA.gov is able to keep their branding while Parature widgets run in the background.

image

Users are able to interact with the site and perform a search to find blogs or KB articles:

image

Fred then shows how Konami uses Parature to pull the knowledge base information into Facebook so that customers can search within Facebook for similar issues to their problem.  Parature is currently running on 6 of the top 10 Facebook apps.

image

Fred then becomes a call service rep and shows off the new Unified Service Desk and how it can pull in Call Scripts and multiple CRM 2013 tabs into one screen.

image

Fred then receives a phone call which automatically pulls up the customer’s record within the Unified Service Desk. 

image

Using the customer’s CRM record, Fred can then view the location of the customer in order to help solve the case.

image

Fred uses the call script to easily open up a New Case form within CRM and creates a case for his customer

image

The Unified Service Desk looks to be pretty slick and could definitely help customer service reps provide a better customer experience.  We hope the telephony integration comes out of the box and would love to see the Unified Service Desk be fully customizable as we know each agent is unique in how they work.

 

Operate Dynamically

image

Kirill then brings out a Sonoma Partners customer, New Belgium Brewing Company, onto the stage to show how they use Microsoft Dynamics to help with their operations.  Travis Mirrison (IT Director) and Kaitlyn Peot (Sales Support Swashbuckler) talk about how they use technology to enable their sales team to have real time insight and communications with their “Mothership” (home office) back in Fort Collins, Colorado. 


New Belgium then shows off the Rangerland app (built by Sonoma Partners!) and how their sales team can use it to make sure their beer is being sold appropriately.  With a few simple touches, their sales team can easily flag any issues with their product while they are onsite at a seller.

image

image

 

Conclusion

Overall the keynote felt very organized and had a great response from the audience.  Microsoft was able to fill in more details on how the recent acquisitions will help move Dynamics forward and fill in some gaps that were previously missing.  Microsoft also makes a strong play with their variety of products such as Office and Windows 8.1 and how they can integrate to provide a full blown experience for users.  We are looking forward to getting our hands on the Spring Update as it seems to be pretty promising!

CRM DevTools 1.1 is now available!

Posted by on February 25, 2014 in   |  Microsoft Dynamics CRM,   |  Microsoft Dynamics CRM 2011,   |  Microsoft Dynamics CRM 2013  |  commentsComments (0)

I am excited to announce a new release of Dynamics CRM DevTools!  This release provides many additions and enhancements to an already featured packed extension.  Head here for the latest version and see below for a detailed list of updates.

Form

form

  • The form tab will now automatically hide when CRM DevTools is opened from a non-record form page in CRM
  • Copy Record URL provides the ability to copy the real URL of the current record which is often disguised in CRM 2013 due to the single page framework
  • Form Type was updated to display the name of the form type as well as the integer value
  • “Is Dirty” was replaced with Dirty Fields which will display a comma delimited list of dirty fields


User

user

  • User Roles was added to display a comma delimited list of roles for the current user


Find

find

  • Current User will display the name of the current user and the ability to navigate to the record
  • Open Record was added to provide the ability to navigate to a selected entity with the provided record Id
  • Find Type Code was added to display the type code for a provided entity name
  • Find Attribute was updated to use a picklist of available attributes rather than a text box


Fetch

fetch

  • Fetch XML input now provides highlighting, auto-completion of nodes and intellisense


Plugins

image

  • The Plugins tab is brand new and displays all registered plugin assemblies and their details (entity, filtering attributes, and stage)
  • Displays number of successes, crashes, and failures for any sandbox plugin (sandbox only)
     

DB & Server

database

  • The DB & Server tab is brand new and displays information about the Config and MSCRM databases as well as the CRM Server (if user access allows)

  • Config and MSCRM Database info
    • Data Source
    • Initial Catalog
    • Timeout
    • Integrated Security
  • Server info
    • OS Version
    • .Net Framework
    • Name
    • CRM File Path

CRM 2011 UR 16 is Available!

Posted by on February 14, 2014 in   |  Microsoft Dynamics CRM,   |  Microsoft Dynamics CRM 2011  |  commentsComments (2)

Update Rollup 16 for CRM 2011 is now available and it is massive! This update provides more than 140 fixes and roughly 50 of them are for the Outlook client. It is good to see that Microsoft is still hard at work optimizing and fixing CRM 2011 issues. Update Rollup 15 focused on Outlook client improvements so with Update Rollup 16, users should be seeing vast improvements in the Outlook client compared to previous versions.

UR 16 also provides some key UR 12 fixes as well:

  • Reports do not render correctly after applying CRM 2011 Update Rollup 12.
  • After applying Update Rollup 12 on the Microsoft Dynamics CRM 2011 Server, users of the offline edition of the Microsoft Dynamics CRM 2011 Client for Outlook are unable to configure their Offline Scheduled Sync settings under Personal Settings.
  • After Update Rollup 12, datetime picklist does not show the selected value when opened.
  • Cannot use print preview for draft replied emails with images after Update Rollup 12 & 13.

Head here for the full list of fixes (be prepared to scroll for awhile!) and here for the download.  As with all Update Rollups, be sure to regression test on a development environment first before applying to production.

Wanted: CRM DevTools Feedback

Posted by on February 12, 2014 in   |  Microsoft Dynamics CRM,   |  Microsoft Dynamics CRM 2011,   |  Microsoft Dynamics CRM 2013  |  commentsComments (1)

Two weeks ago we released the Dynamics CRM DevTools Chrome extension and so far we have received a great response from the community. In just two weeks time the CRM DevTools hit over 400 users! We want to keep enhancing the DevTools so we created a forum here where would love to hear any feedback on what could make your everyday customizing, developing, and administration easier that we can leverage through this tool.

We are currently working hard on an update to provide even more functionality as well.  Below is a sneak peek of the new Fetch tab enhancements that will provide Fetch XML highlighting, auto-closing of nodes and intellisense!

 

image

 

Look out for an update in the near future with these enhancements and much more!

Fun with Numbers (and Dynamics Workflows)

Posted by on January 30, 2014 in   |  Microsoft Dynamics CRM,   |  Microsoft Dynamics CRM 2011,   |  Microsoft Dynamics CRM 2013  |  commentsComments (0)

An often overlooked feature of CRM is the ability to easily update numeric fields using simple calculations without having to invest in the services of a developer.  Power users, administrators, and business analysts can use workflows to add, subtract, and multiply data in numeric fields.

A simple case of this would be to have a field Contact entity that tracks the number of phone calls made to the Contact.  This field can then be used in reports / dashboards for you to further target your highly active Contacts to drive future business, or even send a slightly better holiday gift as a thank you for their continued business.

The first thing you’ll want to do is create a numeric field (whole number, currency, decimal, or floating point number).  I’ve added a “# of Phone Calls” whole number field to my Contact form.

image

Then create a workflow to run off of Phone Call creation, and the only step needed is an Update step to update the Contact record.

image

In this step, click in your numeric field, and click the drop down for Operator.  You’re able to set the field to a specific value, clear it, or use one of the simple math functions provided to perform easy calculations.

image

image

Now you can create your phone calls and watch your calculated field increment up with each workflow.  You can obviously put in conditions in your workflow in case you only want to count phone calls that are completed, and not all phone calls.  Or you can even add workflows for the other activity types in case you’re not interested in just a workflow count, but an overall count of activities made to contacts, or even accounts.  Finally, you can add workflows around the deletion event of these activities to decrement the count if you allow your users to delete activity records.

image

An additional use case for this native functionality would be to roll up child line item costs/expenses/sales, to a parent record.  A custom entity could be create to track time for professional service firms.  The time records could then roll up to the parent project record to track the overall hours logged against the project, and even be multiplied by the hourly rate to track the overall budget spent at the project.

This functionality, which offers basic math, allows non technical folk to add powerful business logic to their solution, and is often overlooked for the more complex / more expensive “custom development” solution.

Introducing Dynamics CRM DevTools!

Posted by on January 27, 2014 in   |  Microsoft Dynamics CRM,   |  Microsoft Dynamics CRM 2011,   |  Microsoft Dynamics CRM 2013  |  commentsComments (2)

I am happy to announce Dynamics CRM DevTools, our new free developer tool for Dynamics CRM 2013 and 2011 UR 12+.  CRM DevTools is an extension to Google Chrome which can be found here in the Chrome web store.  This extension provides a variety of tools to help optimize customizing and troubleshooting within Dynamics CRM.  Currently all deployments of CRM 2013 and CRM 2011 UR 12+ are supported.  Below is usage information and a full list of features.

Usage

 

Form Information

image

  • Displays the current form’s back-end information

    • Entity Name
    • Entity Id
    • Entity Type Code
    • Form Type
    • Is Dirty
  • Ability to show the current form’s attribute’s schema names
  • Ability to refresh the current form
  • Ability to enable disabled attributes on the current form (System Administrators only)
  • Ability to show hidden attributes on the current form (System Administrators only)

 

Current User Information

image

  • Domain Name
  • User Id
  • Business Unit Id

 

Find

image

  • Ability to open advanced find
  • Set focus to a field on the current form
  • Display a specific User and navigate to the record (by Id)
  • Display a specific Privilege (by Id)

 

Test

image

  • Ability to update attributes from the current form (System Administrators only)
    • This is helpful when you need to update values for testing but the fields don’t exist on the form

 

Fetch

image

  • Execute any Fetch XML statement and view the results

Sonoma Partners’ Editable Grid 2011 v 1.0.38.112688 Released

Posted by on January 15, 2014 in   |  Microsoft Dynamics CRM,   |  Microsoft Dynamics CRM 2011  |  commentsComments (2)

A new version of the Sonoma Partners’ Editable Grid for Dynamics CRM 2011 has been released.  The latest version is available for download immediately via the Sonoma Partner’s Community Site.

This version of Editable Grids for CRM 2011 fixed a few defects:

  • Fixed a script error when changing views on the editable grids in Outlook 2010
  • Fixed inability to tab out of lookup attributes
  • Fixed errors on decimal attributes
  • Provided a friendly error message when a user tries to save the editable grid with an invalid date format

Sonoma Partner’s Editable Grids is a utility that allows users to quickly and easily update multiple records at one time. The editable grid button is accessed in the application ribbon, so users can always access it quickly. The editable grid button is available on Account, Contact, Opportunity, Lead, and Case out of the box, but can be added to more entities through configuration.

Note that this release of Editable Grids is for Dynamics CRM 2011 only and not Dynamics CRM 2013.  These are two separate solutions that Sonoma Partners provides for the latest two major releases of CRM.

This is a free tool that Sonoma Partners makes available to the community.  Head over to the Community Site now and download your copy!

CRM 2013 Custom Actions - The End of Configuration Entities

Posted by on November 11, 2013 in   |  Microsoft Dynamics CRM 2011,   |  Microsoft Dynamics CRM 2013  |  commentsComments (7)

CRM 2013 adds a new handy feature called Custom Actions.  Custom Actions provide the ability for non-developer administrators to write reusable modules of logic that developers can trigger through client-side or server-side code.  Custom Actions are built using a similar UI as workflows with the same capabilities.  The actions are run synchronously and can take in parameters as well as return values.  Custom Actions can be pretty powerful and are a great way to share logic between both JavaScript and plugins.  Below is a great example we came up with to show how we can replace a 2011 style configuration entity with 2013 Custom Actions. 

In CRM 2011, if you need to reference values in code that would change between deployments, the best practice is to create a new entity (typically called Configuration) and add necessary attributes for configurable values such as a “Server URL” of an integration web service.  The sole purpose of this entity is to hold one record that would contain the correct values that your custom code can reference, usually for integration purposes.  The downside to this approach is that it adds overhead by needing to create a whole entity that will only ever have one record and you need to manually import that record into your target environment.  Below is a step-by-step guide on how we can avoid a configuration entity in CRM 2013 using Custom Actions.

In CRM 2013, go to Settings and then Processes.  Create a new Process and set the Category to “Action” and the Entity to “None (global)”.

image

Once the process is created, click the plus icon to add a new argument and set the name to the configuration value such as “ServerUrl”.  Set the Type appropriately based on your value and set the Direction to Output.  Do this for each configuration value needed.

image

Scroll down to the designer and click “Add Step” and then “Assign Value”.

image

Click Properties and in the new dialog window, type in the value for your configuration attribute.image

Now save and activate your new custom action.

The custom action is now live so we can use the CrmSvcUtil to generate an SDK message for the action so that we can easily use it with server-side code.  You can use the CrmSvcUtil the same way in 2013 as you did in 2011 but you will need to add the “/a” flag to generate an SDK message for your custom actions.

Note:  You will need the latest CrmSvcUtil which is provided here in the 2013 SDK.

CrmSvcUtil /url:http://server/org/XRMServices/2011/Organization.svc /out:Demo.cs
/serviceContextName:DemoContext /namespace:Demo.Model /a

Now we can reference the new_GetConfigurationValuesRequest and execute it to get the ServerUrl value from CRM.  Even though we specified the custom action as global, we are still required to pass in an EntityReference otherwise CRM will throw an error.  Our workaround for this is to pass in the ID of the current user. 

var request = 
     new new_GetConfigurationValuesRequest()
     {
          Target = new EntityReference("systemuser", GetCurrentUserId()),
     };

var response = (new_GetConfigurationValuesResponse)_service.Execute(request);
var url = response.ServerUrl;

So there you have it!  Executing this request returns “http://server” that I had set in the custom action and now we can use it to replace a configuration entity.  As you can see, custom actions can be pretty powerful.  One improvement we’re hoping for in the future is to allow custom actions to execute custom code, similar to a workflow assembly.  This would allow developers to easily kick off server-side code from JavaScript.


Contact Us for a Quote, or Personalized Demonstrationof Salesforce.com or Microsoft Dynamics CRM for Your Business.

Contact Us