Tuesday, March 31, 2015

Export all entity field values to Excel file



In a previous post, I mentioned that it's possible to use the Open Source "ClosedXML" .NET library in a Dynamics CRM plug-in, even with CRM Online. In addition to using ClosedXML for importing data into CRM and executing formulas, it's also useful as a way to export data from CRM. For example, I recently created a solution for exporting all field values for an entity to an Excel file. The image below illustrates this functionality.


When developing forms, business processes or troubleshooting issues, it's often useful to see the value for all fields for an entity, not just the fields on the form. This tool (packaged as a managed solution) will provide a simple way to add this capability.

The "Export All Field Values" ribbon button creates a record of type "Excel Export" (a custom entity). A plug-in (that incorporates ClosedXML) fires, queries for the entity metadata, queries for all field values, creates the Excel file and attaches it to the new entity record. The ribbon button's JavaScript pops open the Excel Export entity for the user, so all the user needs to do is click the Excel file attachment to open the file.

It's expected that only CRM administrators and customizers will need this export functionality but I included a security role in the solution as well to allow an admin to assign the role to other users as needed. For example, someone testing functionality in CRM might want an easy way to see all field values.

No comments:

Post a Comment