|
31.12.2008, 00:08 | #1 |
Участник
|
Microsoft Dynamics CRM Team Blog: Just do it – Deleting attributes that are in use by running Workflows
Источник: http://blogs.msdn.com/crm/archive/20...workflows.aspx
============== 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. Cheers, Aaron Elder This posting is provided "AS IS" with no warranties, and confers no rights. Источник: http://blogs.msdn.com/crm/archive/20...workflows.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
|