Thursday, May 5, 2011

How to Check In & Check Out Publishing Page using workflowProperties when SPContext.Current return NULL Valure

Source  for Actual Post:  How to Check In Check Out Publish a document using workflowPropertie


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

Featured Post

Protect an API by using OAuth 2.0 with Azure Active Directory and API Management

Protect an API by using OAuth 2.0 with Azure Active Directory and API Management https://docs.microsoft.com/en-us/azure/api-management/api-...

Popular posts