Javascript not loading for users with Read permission

I have a custom code snippet page in SharePoint 2010 that loads various js and css files. The page functions fine for me and other super users but not for users with Read access. Debugging the script it clearly shows the script files are not loaded.

It seems that even though all the files are checked in users with read access cannot see them. You must ensure that all these files have a published version i.e. publish a major version after checking them in. Easy enough to miss this one as there is no clear error message.

Some resources:

Bulk check-in and publish via PowerShell:

#Add SharePoint Snapin if not using SharePoint’s PowerShell Console
if((Get-PSSnapin-NameMicrosoft.SharePoint.PowerShell-ErrorActionSilentlyContinue) -eq$null)
{
Add-PsSnapinMicrosoft.SharePoint.PowerShell
}
#First function takes ownerhip of all unmanaged files with no version
functionTake-Ownership{
param(
$spSite,
$spList
)
$site= Get-SPWeb-Identity$spSite
$list= $site.Lists[$spList]

$list.CheckedOutFiles | ForEach-Object{
$_.LeafName+ ” had it’s ownership taken from: “+$_.CheckedOutBy.DisplayName+”`n”
$_.TakeOverCheckOut()
}
}
#This Function takes a folder object and recursively checks in
#all files which are checked out by the System Account
functioncheckin-AllFiles{
param(
[Parameter(Mandatory=$true, ValueFromPipeline=$true)]
[Microsoft.SharePoint.SPFolder]
$currFolder
)

$currFolder.Files | ForEach-Object{
if($_.CheckedOutByUser.UserLogin -eq”SHAREPOINT\system”){
$_.CheckIn(“File checked in by administrator”)
“To Publish the files add this line”
$_.Publish(“Automatic Publish. (Administrator)”)
$_.Name+” has been checked in`n”
}
}
$currFolder.SubFolders| ForEach-Object{
checkin-AllFiles-currFolder$_
}
}
#This function basically combines the previous 2 for primary use
functionCheckin-AllUnmanagedFiles{
param(
$site,
$library
)
$spSite= Get-SPWeb-identity$site
$spFolder= $spSite.Folders[$library]

Get-Date
“Taking ownership of the following Files`n”
Take-Ownership-spSite$site-spList$library
“—————————————————————————–`n”

Get-Date
“Checking in the following files`n”
checkin-AllFiles-currFolder$spFolder
Get-Date
}

PS> Checkin-AllUnmanagedFiles -site “http://yoursite/” -library “Library Name”

Leave a Reply

Your email address will not be published. Required fields are marked *