Microsoft Dynamics CRM Team Blog: Just do it – Deleting attributes that are in use by running Workflows
Microsoft Dynamics CRM MVP Aaron Elder of Ascentium provides some tips and tricks.
Recently, we had the need to delete several attributes from an entity we had created (Employee). Normally this is a very straight forward affair in Microsoft CRM. You simply remove the field from the Form and Grids and they using the Entity Editor select the attribute and hit “delete”. In this case, the attributes in question, were being used by workflow. Unfortunately, the error you get from CRM is not terribly helpful:
While the steps to take are indeed correct and actually rather useful, the error does nothing to tell you which Workflow is causing the problem. This was especially a problem for us because we happened to have almost 20 workflows running on the Employee entity and unpublishing and hunting through each of these would have been a real pain. Of course with a little bit of SQL, there is a better way:
1: -- Run this against your Org_MSCRM database 2: DECLARE @EntityYouAreTryingToModify VARCHAR(50) 3: DECLARE @AttributeYouAreTryingToDelete VARCHAR(50) 4: -- TODO: Update these to the entity and attribute you are working with 5: SET @EntityYouAreTryingToModify = 'invoke_employees' 6: SET @EntityYouAreTryingToModify = 'invoke_hardwaremacintoshdesktop' 7: SELECT WFD.WorkflowDependencyId AS 'workflowdependencyid', 8: WF.Name FROM WorkflowDependency AS WFD 9: -- Join out to the Workflow Table to get the Name of the Workflow 10: JOIN Workflow AS WF ON 11: WFD.WorkflowId = WF.WorkflowId AND 12: WF.StateCode = 1 13: WHERE 14: WFD.DeletionStateCode = 0 AND 15: WFD.DependentEntityName = @EntityYouAreTryingToModify AND 16: WFD.DependentAttributeName = @EntityYouAreTryingToModify AND 17: WFD.Type = 8 AND 18: WF.DeletionStateCode = 0
This query, will return a list of the Workflows that are currently published and that have a dependency to the field you are trying to delete.
Now that you know what Workflows are causing the problem, the steps to fix this are pretty simple:
1. Unpublish the Workflow(s)Now, if you happen to instead:
1. Unpublish the Workflow(s)
You are going to run into a “Generic” error when you try to re-publish the Workflow. This is because the CRM delete attribute process is smart enough to delete the dependencies from part of the Workflow, but not all. If you find yourself in this situation, don’t worry… just open the Workflow editor using the User Interface, remove the dependency and “re-save” it.
The Workflow UI XML and various other XMLs will get “re-updated” with the dependency removed. You can now re-publish the workflow and all should be well.
This posting is provided "AS IS" with no warranties, and confers no rights.
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
|Microsoft Dynamics CRM Team Blog: List Web Part for Microsoft Dynamics CRM 4.0 Deployment Scenarios||Blog bot||Dynamics CRM: Blogs||0||30.01.2009 22:05|
|Microsoft Dynamics CRM Team Blog: Microsoft Dynamics CRM 4.0 Bookshelf||Blog bot||Dynamics CRM: Blogs||1||22.01.2009 04:46|
|Microsoft Dynamics CRM Team Blog: Highlight: Available downloads for Microsoft Dynamics CRM||Blog bot||Dynamics CRM: Blogs||0||05.11.2008 22:05|
|Microsoft Dynamics CRM Team Blog: Data Migration Manager Tips and Tricks||Blog bot||Dynamics CRM: Blogs||0||02.09.2008 22:05|
|Microsoft Dynamics CRM Team Blog: Top 14 Microsoft Dynamics CRM Sites and Downloads||Blog bot||Dynamics CRM: Blogs||0||14.07.2008 13:05|
|Опции темы||Поиск в этой теме|