I have a WebPart that is creating some items in a list, about 10-20 at a time. I also have a SPD workflow associated to that list. When items are created workflow doesn't start on all the items. Sometimes it starts on 6 items out of may be 20 or 10 items created, and sometimes only one 1 or 3 items created. The workflow never starts on more than 6 items. I also have another workflow in the same list and the same behavior.
i created a brand new list and brand new workflow to test this out and same result, i don't know if it is a SharePoint online thing? below is my code.
for (int i = 0; i < Convert.ToInt32(TextBox2.Text); i++)
{
SPListItem item = list.AddItem();
item["Title"] = "abc" + i;
item["Date"] = DateTime.Today;
item["Employee"] = web.CurrentUser;
item["Hours"] = i;
item["Description"] = "abc" + i;
item["New Balance"] = i;
item["Action"] = "Expired";
item["Leave Type"] = getLookUpValue("Sick", list, "Leave Type");
item.Update();
}
when i tried this line below:
//Microsoft.SharePoint.Workflow.SPWorkflowAssociation wfAssoc = transItem.ParentList.WorkflowAssociations.GetAssociationByName("Update Balance", System.Globalization.CultureInfo.CurrentCulture);
//transItem.Web.Site.WorkflowManager.StartWorkflow(transItem, wfAssoc, wfAssoc.AssociationData, true);
all the workflows start and work fine, but i would like not to use this, as there maybe more workflows get added to the list and they will fail to start since they are not to start by this code.
also tried WorkflowManger.Dispose() as i read online but no help.
Thanks in advance.