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

Mention a Channel or Team – Power Automate

Mention a Channel or Team – Power Automate graph.microsoft.com/v1.0/teams/{teamId}/channels/{channelId}/messages Channel: ---------- {   &qu...

Popular posts