How to: delete entity attributes using Excel import in Dynamics

By | August 7, 2018

Note: this solution was updated to v 1.0.1 on Aug 9. Instead of the original workflow activity, there is a plugin and an SDK step now. It turned out custom workflow activity was causing Generic SQL Errors in some environments.

If you just asked “what?!” after reading the title, I guess my mission has already been half accomplished. Catchy subjects and all that..

But, seriously, we don’t always have the luxury of automated deployment on our projects, so we often have to do a lot of stuff manually when maintaining Dynamics environments. And one of those things which I found causing a bit of a problem is making sure that all the attributes that were supposed to be deleted have, actually, been deleted.

As in.. While working in the sandbox environment, we may choose to delete an attribute. But we also need to remember to delete it from production when the time comes. And, of course, in the absence of automated deployment, deleting an attribute is, often, the last of our concerns since, after all, having an extra attribute is unlikely to break anything. And going over a bunch of attributes does take time.. not surprisingly, we may simply choose to keep them in production this time.. and the next time.. and, eventually, we won’t know what’s needed and what’s not anymore.

So, to make it a bit easier, what if we could list all deleted attributes in a spreadsheet, and, then, import that spreadsheet to the production environment? Of course it would not help much unless there were some code that would process the spreadsheet to actually delete the attributes.

This is exactly what “Solution Management” project is about:

https://github.com/ashlega/SolutionManagement

Here is how it works:

1. You will need to download and deploy the managed solution (or you can use unmanaged – totally up to you)

image

2. With this solution, a few components will be deployed

  • Solution Action entity

 

image

  • A plugin and an SDK step registered to run OnCreate (pre-validate) of the Solution Activity

3. To use the solution, you would need to create Solution Action records in the production environments, so the workflow would take care of deleting the attributes. Using excel import might be one of the easiest options for that

  • Start by downloading the import template for the Solution Action entity

 

image

  • Open the spreadsheet and fill in the data – you only need to provide Action, Entity, and Attribute names

 

image

  • This is important: make sure you have deployed the customizations which remove dependencies for the attributes being deleted. The workflow will not be deleting the dependencies – it will only try to delete the attribute. If this sounds like a limitation, think of it this way: assuming you are not using the attribute, there should be no dependencies. By this time, you would normally have worked through that while customizing the forms/views/charts/dashboards, etc. In other words, this is not something you need to do manually in production – you just need to bring over your customizations (as a solution) from sandbox/development to production.
  • Finally, import the spreadsheet to Dynamics

 

image

You may want to give the workflow a few minutes to complete, since it’s a background workflow. And, then, you can go to the advanced find and have a look at the Solution Actions:

image

Believe it or not.. We’ve just deleted an attribute using Excel import!

 

2 thoughts on “How to: delete entity attributes using Excel import in Dynamics

  1. Guus

    Hi Alex, great stuff! Does this also work for creating attributes? Recently, we used AttributeEditor from the Xrm toolbox for that but its not working pretty well. We would like to add all types of fields like option sets, string, etc.

    Reply
    1. Alex Shlega Post author

      Hi Guus,

      nope:) This one is extremely simple – you don’t need to do a lot to delete an attribute. Adding an attribute would be a different story – there would be a lot of settings, many of them would be datatype-specific.. does not seem to fit well into the tabular structure of the spreadsheets. Why not to use the solutions? You can’t delete attributes that way, but, as far as adding new components (attributes included) goes, I think solutions should cover that part pretty well?

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *