update item code does not trigger wait for field action in workflow created by sharepoint designer

Hello
I have a workflow created by SharePoint Designer which have a "wait for myField to not equals oldValue".
I also wrote a code shown as below to update myField of multiple items. after running code all certain items update to NewValue but workflows of the items stayed at wait.. action and do not trigger and do not continue next actions.
when I change myField in user edit the items manually it does trigger the workflow.
Q: what changes do I have to apply in my code to cause triggering workflows?

using (SPSite oSPsite = new SPSite(""))
{
           using (SPWeb oSPWeb = oSPsite.OpenWeb())
            {
                 oSPWeb.AllowUnsafeUpdates = true;
                 SPList list = oSPWeb.Lists["Mylist"];

                   foreach(SPListItem itemToUpdate in list.Items)
                          if (itemToUpdate["HREC_AirTicket_Status"].Equals("OldValue"))
                            {
                                          itemToUpdate["HREC_AirTicket_Status"] = "NewValue";  
                                            itemToUpdate.Update();
                            }   
                  oSPWeb.AllowUnsafeUpdates = false;
             }
}
   

July 14th, 2013 5:37am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics