locked
SharePoint Workflow Not reading value from list RRS feed

  • Question

  • Hello,

     

    I have created a workflow (W2) in VS 2005 and deployed it. Associated it with a list on item changed. There is another workflow (w1) on the same list which start when item is created. So W1 fires when user creates a new entry. It updates value on a particular field in the list. When this happens W2 fires but in the code I have put a while loop which check the value for the field just changed. This while loop runs until the W1 changes it's value again. 

     

    The problem is W2 reads the value of the list column on 1st update but does not read the value on second update and gets stuck in an infinite loop.

     

    This is how I am reading the value:

    while (workflowProperties.Item["Workflow Status"].ToString() != "Approved by Ops")
         {
            
            dummy++;
          }
    

    Can anyone tell me why the while loop is not picking up the value from the list the second time update is made.

    Friday, April 1, 2011 4:10 PM

Answers

  • I believe that if you are checking workflowProperties, that these values are not updated during the workflow cycle.  The values seem to be copied into the workflow instance itself.

    Perhaps you could create an event handler on the list that will detect the value changed and if it is set to "Approved by Ops", you could then have the Event Handler kick off the workflow directly. 

    This may also be better then putting the workflow it in an infinite loop.  The WF model should come alive, do a task, and go back to sleep.

    Also, you could go to the actual list data value and check to see if it was updated.  I do this in one of my workflows, but it is more complicated (then what you are trying to do).  If you are really set on this, let me know and I can provide a sample of how I did this.

    Dennis

    • Marked as answer by Peng Lei Monday, April 11, 2011 9:04 AM
    Friday, April 1, 2011 10:02 PM

All replies

  • I believe that if you are checking workflowProperties, that these values are not updated during the workflow cycle.  The values seem to be copied into the workflow instance itself.

    Perhaps you could create an event handler on the list that will detect the value changed and if it is set to "Approved by Ops", you could then have the Event Handler kick off the workflow directly. 

    This may also be better then putting the workflow it in an infinite loop.  The WF model should come alive, do a task, and go back to sleep.

    Also, you could go to the actual list data value and check to see if it was updated.  I do this in one of my workflows, but it is more complicated (then what you are trying to do).  If you are really set on this, let me know and I can provide a sample of how I did this.

    Dennis

    • Marked as answer by Peng Lei Monday, April 11, 2011 9:04 AM
    Friday, April 1, 2011 10:02 PM
  • Thanks for your response Dennis. Can you give me a sample of reading the list data from the workflow to see if it is updated.

     

     


    • Edited by Mike Walsh FIN Saturday, April 2, 2011 7:05 AM Ask your new question in a new thread. Let's keep this one focused.
    Saturday, April 2, 2011 5:47 AM