Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a sandbox solution that deploys an xsl file to the styles library. The solution is scoped to the web and what happens is when the solution is deployed, the xsl file is stilled checked. Now I have a solution to resolve this matter, but is there reason why this happens? I do have Publishing activated on the site collection level.

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

This is standard behavior for sandboxed solutions. I'm glad to hear you already have a fix to ensure your file gets checked in. For those that don't, I've written up a guide on my blog: http://thechriskent.com/2012/04/05/auto-publish-and-approve-your-solution-files-2/

To summarize, in the FeatureActivating event handler you will need to loop through each deployed file and check them in and/or approve them depending on the settings of the library.

Check out the post for more details, but here is the basic code I use for all of my files deployed to the Style Library (Runs in the FeatureActivating event handler):

Dim styleLibrary As SPList = topSite.Lists.TryGetList("Style Library")
If styleLibrary IsNot Nothing Then
    Dim folders As SPListItemCollection = styleLibrary.Folders
    Dim item As SPListItem = DirectCast((From i In folders Where DirectCast(i, SPListItem).Url = "Style Library/RICBranding" Select i).FirstOrDefault(), SPListItem)
    ApproveAndPublish(item.Folder, styleLibrary.EnableModeration)
End If

Here is the helper method called above that I use to recursively check in/approve the files in all the subfolders:

Private Sub ApproveAndPublish(folder As SPFolder, Approve As Boolean)
    If folder Is Nothing Then Return
    For Each subfolder As SPFolder In folder.SubFolders
        ApproveAndPublish(subfolder, Approve)
    Next
    For Each file As SPFile In folder.Files
        If Not file.CheckOutType = SPFile.SPCheckOutType.None Then
            file.CheckIn("Feature Activation", SPCheckinType.MajorCheckIn)
            If Approve Then
                file.Approve("Feature Activation")
            End If
        End If
    Next
End Sub
share|improve this answer
add comment

This is a known behaviour for modules in the sandbox.

You should be able to added a Feature reciever on the feature that deploys your module, in that itterate through the target library and publish the list items that match your deplyed xslt files/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.