I have created a SharePoint 2010 workflow to send an email on list. when I add item into list using code, it not triggers the workflow. however when I enter Item manually it works fine.
-
Are you using RunWithElevatedPrivileges? The workflows don't work when you are using System Account to add item..– Arsalan Adam KhatriSep 12, 2018 at 11:46
-
Yes I am using RunWithElevated, However I need it because not all users have the pemission to create list item.– RameshSep 12, 2018 at 12:07
-
Through code, are you able add item? did you check whether the item is there or not?– ArulrajSep 12, 2018 at 12:56
-
@Ramesh this might help sharepoint.stackexchange.com/questions/56751/…– Arsalan Adam KhatriSep 12, 2018 at 13:38
2 Answers
A common issue is that workflow not starting automatically as System Account. So don't run the code with system account.
Similar issue post for your reference:
I had the same issue. I went through the following:
- I checked SPTimerV4-- it was running.
- I ran Get-WFFarmStatus and Get-SBFarmStatus-- both were good.
- WF running as System Account: false-- all good.
- Item being created by System Account: false-- all good.
- Checked/unchecked manual start/auto start in Designer, then republished-- done.
None of them worked. (You can google each of the above to perform them accurately.)
At the end of my wits, I thought of recreating the WF. I began with a simple workflow that did nothing but to log a message on the history list. I checked manual/auto at creation. Saved and published. I created an item in the target list.
This new WF ran-- and so did the old problematic WF!
I am thinking that there is an internal create-event hook that broke with the old WF. When the new WF was being hooking into the create event, it restored the hook for the old WF. I will probably never get to confirm this. Just the same, it resolved my issue and that is what matters to me now.
TGBTG!