문제

I have a Custom List and the list attached with SharePoint Designer 2007 workflow where trigger when new item created.

If I programmatically create an item in a Custom List, will the action trigger the workflow?

below is the code fragment for programmatically create item in a Custom List.

using (SPSite site = new SPSite(_url))
{
    using (SPWeb web = site.OpenWeb())
    {
        web.AllowUnsafeUpdates = true;

        SPList list = web.Lists["CustomListName"];
        SPListItem newItems = list.Items.Add();

        newItems["Title"] = "test";

        newItems.Update();

        web.AllowUnsafeUpdates = false;
    }
}

I've tried the code above and new item successfully created in the Custom List, but the workflow was not trigger, any idea?

Please help.

Thank you in advanced

도움이 되었습니까?

해결책

A common issue is that SP1 had a security fix which prevents declarative workflows to start as the system account(as described here). So if you're running the code above as System then that's the cause.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top