Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Event receiver to publishing automatically documents

$
0
0
Hey


i´m trying create a event receiver to publishing automatically documemnts when they are downloaded to sharepoint. 

Imagine the situation, when i adding documents using the option open in browser... the documents are added to my Document Library but all of them are not publishing... i´m trying create a event receiver to do this automatically. 


Take the code: 


public override void ItemAdding(SPItemEventProperties properties)
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
              {
                  properties.Web.AllowUnsafeUpdates = true;
                  //properties.ListItem.ModerationInformation.Status = SPModerationStatusType.Approved;

                  properties.ListItem.File.Level = SPFileLevel.Published;
                  base.ItemAdding(properties);
                  properties.Web.AllowUnsafeUpdates = false;
              });
        } 



Error1Property or indexer 'Microsoft.SharePoint.SPFile.Level' cannot be assigned to -- it is read only

thanks for help



Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>