Wednesday 4 May 2011

How to Check In Check Out Publish a document using workflowProperties

                  Almost one week I am getting bored with this task how to check in, check out, publish a document using SPContext.Current.   Each and every time it returns the NULL value.  I cant get any valuable post regarding this mistake.  Finally I got this solution using workflow properties.  This is working well in SP2007 sequential workflows in VS2008.
          
            SPSite oSite = new SPSite(workflowProperties.SiteId);
            SPWeb oWeb = oSite.OpenWeb();
            SPList oList = oWeb.Lists[workflowProperties.List.Title.ToString()];
            //SPList oList = oWeb.Lists["Pages"];
            SPListItem item = oList.GetItemById(workflowProperties.ItemId);
          
            SPFile file1 = item.File;
            file1.Publish("Published by  " + workflowProperties.Web.CurrentUser.Name);
            file1.Approve("Approved by Administrator ");

           If you want to Check in
                                file1.Checkin("chek in ");
     
           If you want to Check out
                                 fil1.Checkout( );



          




No comments:

Post a Comment