none
Workflow XML

    Question

  • I have 2 workflows that update the custom property 'Assigned' anytime the Assigned To relationship is added or deleted.  My issue is that it seems to work properly only a quarter of the time, specifically when the assigned to field is cleared, click apply on the incident form, then fill it in with another user, apply again.  Both workflows run at this point, at almost exactly the same time so the best I can guess is that the <AddRelationship> WF is running before the <DeleteRelationship>.   I would think the WFs would be processed in the same order in which they are invoked.  ie DeleteRelationship happened first so that WF is processed first.

    AddRelationship should update Assigned to the value of 1.

    DeleteRelationship should update Assigned to 0.

    Most of the time after the above process and execution of the WFs I end up with Assigned = 0.  If I delete the Assigned to name and click on Apply, wait for the WF to process, then add in another User and click Apply, it works every time.  Here is the XML.  The bold text are things I've been playing with.

     

     

       <Rules>
          <Rule ID="IncidentAssignedToUserAddRule" Enabled="true" Target="IncidentManagement!System.WorkItem.Incident.Wizard.AutomaticChangeIncident" ConfirmDelivery="true" Remotable="true" <strong>Priority="Normal"</strong> DiscardLevel="100">
            <Category>System</Category>
            <DataSources>
              <DataSource ID="DS" TypeID="SystemCenter!Microsoft.SystemCenter.CmdbInstanceSubscription.DataSourceModule">
                <Subscription>
                  <RelationshipSubscription RelType="$MPElement[Name='WorkItem!System.WorkItemAssignedToUser']$" SourceType="$MPElement[Name='CoreIncident!System.WorkItem.Incident']$" TargetType="$MPElement[Name='System!System.Domain.User']$">
                    <AddRelationship />
                  </RelationshipSubscription>
                 <strong> <PollingIntervalInSeconds>30</PollingIntervalInSeconds>
                  <BatchSize>100</BatchSize></strong>
                </Subscription>
              </DataSource>
            </DataSources>
            <WriteActions>
              <WriteAction ID="WA" TypeID="SystemCenter!Microsoft.EnterpriseManagement.SystemCenter.Subscription.WindowsWorkflowTaskWriteAction">
                <Subscription>
                  <EnableBatchProcessing>false</EnableBatchProcessing>
                  <WindowsWorkflowConfiguration>
                    <AssemblyName>Microsoft.EnterpriseManagement.ServiceManager.Incident.Workflows</AssemblyName>
                    <WorkflowTypeName>Microsoft.EnterpriseManagement.ServiceManager.Incident.Workflows.AutomaticIncidentChangeWorkflow</WorkflowTypeName>
                    <WorkflowParameters>
                      <WorkflowArrayParameter Name="InstanceIds" Type="guid">
                        <Item>$Data/BaseManagedEntityId$</Item>
                      </WorkflowArrayParameter>
                      <WorkflowParameter Name="IncidentTemplate" Type="guid">$MPElement[Name='IncidentAssignedPropertyChange']$</WorkflowParameter>
                      <WorkflowParameter Name="NotificationRulesEnabled" Type="boolean">false</WorkflowParameter>
                      <WorkflowArrayParameter Name="NotificationTemplates" Type="guid">
                        <Item>$MPElement[Name='IncidentAssignedToUserNotificationTemplate']$</Item>
                        <Item>$MPElement[Name='Template_ddb42d85ab9747e583170d171f47c851']$</Item>
                      </WorkflowArrayParameter>
                      <WorkflowArrayParameter Name="UserAliasOrRelationships" Type="string">
                        <Item>$MPElement[Name='WorkItem!System.WorkItemAssignedToUser']$</Item>
                        <Item>$MPElement[Name='WorkItem!System.WorkItemAffectedUser']$</Item>
                      </WorkflowArrayParameter>
                    </WorkflowParameters>
                    <RetryExceptions />
                    <RetryDelaySeconds>60</RetryDelaySeconds>
                    <MaximumRunningTimeSeconds>7200</MaximumRunningTimeSeconds>
                  </WindowsWorkflowConfiguration>
                </Subscription>
              </WriteAction>
            </WriteActions>
          </Rule>
          <Rule ID="IncidentAssignedToUserDeleteRule" Enabled="true" Target="IncidentManagement!System.WorkItem.Incident.Wizard.AutomaticChangeIncident" ConfirmDelivery="true" Remotable="true" <strong>Priority="High"</strong> DiscardLevel="100">
            <Category>System</Category>
            <DataSources>
              <DataSource ID="DS" TypeID="SystemCenter!Microsoft.SystemCenter.CmdbInstanceSubscription.DataSourceModule">
                <Subscription>
                  <RelationshipSubscription RelType="$MPElement[Name='WorkItem!System.WorkItemAssignedToUser']$" SourceType="$MPElement[Name='CoreIncident!System.WorkItem.Incident']$" TargetType="$MPElement[Name='System!System.Domain.User']$">
                    <DeleteRelationship />
                  </RelationshipSubscription>
    <strong>              <PollingIntervalInSeconds>20</PollingIntervalInSeconds>
                  <BatchSize>100</BatchSize></strong>
                </Subscription>
              </DataSource>
            </DataSources>
            <WriteActions>
              <WriteAction ID="WA" TypeID="SystemCenter!Microsoft.EnterpriseManagement.SystemCenter.Subscription.WindowsWorkflowTaskWriteAction">
                <Subscription>
                  <EnableBatchProcessing>false</EnableBatchProcessing>
                  <WindowsWorkflowConfiguration>
                    <AssemblyName>Microsoft.EnterpriseManagement.ServiceManager.Incident.Workflows</AssemblyName>
                    <WorkflowTypeName>Microsoft.EnterpriseManagement.ServiceManager.Incident.Workflows.AutomaticIncidentChangeWorkflow</WorkflowTypeName>
                    <WorkflowParameters>
                      <WorkflowArrayParameter Name="InstanceIds" Type="guid">
                        <Item>$Data/BaseManagedEntityId$</Item>
                      </WorkflowArrayParameter>
                      <WorkflowParameter Name="IncidentTemplate" Type="guid">$MPElement[Name='IncidentUnassignedPropertyChange']$</WorkflowParameter>
                      <WorkflowParameter Name="NotificationRulesEnabled" Type="boolean">false</WorkflowParameter>
                      <WorkflowArrayParameter Name="NotificationTemplates" Type="guid" />
                      <WorkflowArrayParameter Name="UserAliasOrRelationships" Type="string" />
                    </WorkflowParameters>
                    <RetryExceptions />
                    <RetryDelaySeconds>60</RetryDelaySeconds>
                    <MaximumRunningTimeSeconds>7200</MaximumRunningTimeSeconds>
                  </WindowsWorkflowConfiguration>
                </Subscription>
              </WriteAction>
            </WriteActions>
          </Rule>
        </Rules>
    


     


    Allen Anderson Systems Analyst Arizona State University - OKED Knowledge Informatics
    Wednesday, January 25, 2012 11:27 PM