How to get the context item in Workflow activity (SharePoint)

后端 未结 6 1743
萌比男神i
萌比男神i 2021-02-20 06:56

I am writing custom activity for sharepoint workflow and I don\'t know how I can use current workflow item, SPWeb or SPSite.

I see http://blogs.microsoft.co.il/blogs/dav

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-20 07:41

    I'm not sure if this is a change in the 2010 API but the __Context property provides all the necessary pieces, including the list and item. The example below includes @davek's suggestion for discarding the security context:

                var contextWeb = __Context.Web;
                var site = new SPSite(contextWeb.Url);
                var web = site.OpenWeb();
    
                var list = web.Lists[new Guid(__Context.ListId)];
                var item = list.GetItemById( __Context.ItemId);
    

提交回复
热议问题