0

Ok guys, I've been bending my head over this problem for quite some time now. Let me give you a little bit of context here. I have a site collection feature (FileCentral) working on it's version '1.0.0.0'. What this feature does is to create a document library in which I can upload files that will be stored on a network share. So each item in this document library stores a link to the file path. No problem here. Recently I've got the following requirement: "It should be possible to synchronize files from the folder to the document library". In other words, I need some way to scan for files placed in the network share and create the respective list items pointing to these files. The proposed solution is to create a custom action on this document library that when clicked would open a dialog with a page called SyncFiles.aspx in it. This page would then call an asynchronous service responsible for listing the files that have not been synchronized. The user would then select the files he wants to sync and confirm the operation. The project structure for this solution is:

|Features
|-- FileCentral (Site scoped feature)
|---- FileCentral.feature
|------ FileCentral.Template.xml

|branding (module)
|-- js (folder)
|---- app (folder)
|------ fileCentral (folder)
|-------- home.js
|-- Elements.xml

|Pages (module)
|-- Home.aspx (file)

|Updates (folder)
|-- SyncFileCentral (folder)
|---- Assets (module)
|------ js (folder)
|-------- app (folder)
|---------- fileCentral (folder)
|------------ sync.js
|------ Elements.xml
|---- Button (custom action)
|------ Elements.xml
|---- Pages (module)
|------ SyncFiles.aspx
|------ Elements.xml

The Assets module deploys to the Masterpage Gallery the necessary javascript e css files for the SyncFiles.aspx page to work:

<!-- Assets module -->
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="branding" Url="_catalogs/masterpage" RootWebOnly="TRUE">
    <File Path="branding\js\app\fileCentral\sync.js" Url="branding/js/app/fileCentral/sync.js" ReplaceContent="TRUE" IgnoreIfAlreadyExists="TRUE" Type="GhostableInLibrary" Level="Published"/>
  </Module>
</Elements>

The Button custom action deploys the (guess what?) the custom action. And the Pages modules deploys the SyncFiles.aspx page to the Pages document library.

<-- Pages module -->
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="Pages" Url="Pages" RootWebOnly="TRUE">
    <File Path="Pages\SyncFiles.aspx" Url="Pages/SyncFiles.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" ReplaceContent="TRUE" Level="Published" />
  </Module>
</Elements>

The FileCentral.Template.xml looks like:

<?xml version="1.0" encoding="utf-8"?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/" **Version="2.0.0.0"** Title="File Central" ActivateOnDefault="FALSE" AlwaysForceInstall="TRUE" Description="DESCRIPTION HERE" Id="XXX" Scope="Site">
  <!-- Feature Upgrade -->
  <UpgradeActions>
    <VersionRange BeginVersion="2.0.0.0" EndVersion="3.0.0.0">
      <ApplyElementManifests>
        <ElementManifest Location="Assets\Elements.xml" />
        <ElementFile Location="Assets\js\app\fileCentral\sync.js" />
        <ElementManifest Location="Button\Elements.xml" />
        <ElementManifest Location="Pages\Elements.xml" />
        <ElementFile Location="Pages\SyncFiles.aspx" />
      </ApplyElementManifests>
    </VersionRange>
  </UpgradeActions>
  <ElementManifests>
    <ElementManifest Location="branding\Elements.xml" />
    <ElementFile Location="branding\js\app\fileCentral\home.js" />
    <ElementManifest Location="Assets\Elements.xml" />
    <ElementFile Location="Assets\js\app\fileCentral\sync.js" />
    <ElementManifest Location="Button\Elements.xml" />
    <ElementManifest Location="Pages\Elements.xml" />
    <ElementFile Location="Pages\SyncFiles.aspx" />
  </ElementManifests>
</Feature>

Ok, enough of context. Here is the problem: When I Update-SPSolution -Identity "FileCentralSolution.wsp" -LiteralPath "X" -GACDeployment, I can see ($site.QueryFeatures([Microsoft.SharePoint.SPFeatureScope]::Site, $true)) that there are features needing update. Then, when I update the features, I'm not able to see neither my assets nor my pages changes. The only thing that gets deployed is my custom action. So when I click the button a blank dialog open up. And if I inspect the network tab, I can see the assets and page requests return 404 status responses. WHAT HAVE I DONE WRONG?

mnatan.brito
  • 883
  • 5
  • 18
  • 32
  • Why wouldn't you just access the Document Library through WebDav? It seems like you're going through an awful lot of trouble to recreate OOB functionality... – Michael Bailey Mar 29 '17 at 14:35

1 Answers1

1

Have you checked your file system to see if the files have indeed been deployed to the correct hive? If this is SharePoint 2013, are your solution files being deployed to the folder appropriate to your selected UI mode? (CompatibilityLevel 14,15?)

  • Thank you for your answer @MichaelBailey. I changed the approach. I moved the **SyncFiles.aspx** to the **Pages** module (right beside Home.aspx). Then I moved the **sync.js** to the **branding** module up top inside the **fileCentral** folder. Funny thing comes now: The SyncFiles.aspx returns an HTTP 200 result, but the sync.js file still returns **HTTP NOT FOUND**, even though the folders and files get created inside **16/TEMPLATE/FEATURES/FileCentral**. – mnatan.brito Mar 30 '17 at 02:21
  • I'll sound dumb (I know), but how can I get the files inside the 15 hive not 16? – mnatan.brito Apr 01 '17 at 21:31
  • Install the feature via PowerShell and use the -CompatibilityLevel ALL option. – Michael Bailey Apr 02 '17 at 00:36
  • But I'm already using powershell to update the feature `$site = Get-SPSite http://url; $site.QueryFeatures([Microsoft.SharePoint.SPFeatureScope]::Site, $true);` then I run `$feature.Upgrade($false)` on the features returned from the query features method. – mnatan.brito Apr 02 '17 at 02:21
  • If your CompatibilityLevel is already an issue, then using SPFeature.Upgrade() isn't going to fix it. Try running Install-SPSolution with the Force attribute set and the CompatibilityLevel -All AFTER you update your feature (just this once) to see if it puts everything in the correct location. – Michael Bailey Apr 02 '17 at 20:37
  • Thank you for your answers! So, I guess I still haven't got it working. I retracted the solution (without disabling the features once I have logic intended to run just once on them), then I removed it. Later, I installed the new version of the solution package (using Force and CompatibilityLevel switches you pointed out). I noticed that the features folders get created inside the 14 hive as well **(but not inside the 15)** now. Then, I ran the SPFeature.Upgrade but once again the files didn't get created inside the masterpage gallery )= – mnatan.brito Apr 03 '17 at 03:31
  • Funny thing is: if I add a new file (let's say a javascript file) to an existing module, when I upgrade the features, I can see the file get's created. But if I create a new module and add files to it, add this module to the feature and add the appropriate **ElementManifest** inside the **ApplyElementManifests** pointing to the newly created module and having the appropriate **VersionRange**, then it doesn't work. – mnatan.brito Apr 03 '17 at 03:35