Deploy Solution to subweb only

This topic contains 2 replies, has 2 voices, and was last updated by  Joe McShea 2 weeks, 5 days ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1940

    MichaelH
    Participant

    Hello,
    I think my title is already pretty self explaining 🙂
    So we have a Site Collection (in SPO), which were used in the past to setup a LOT of subwebs. All independent, all with broken inheritance.
    Now I wonder, if there is a chance to make the EasyForms available in certain subwebs only, but not for the whole site collection.

    Already tried to deploy the solution and then restricted the access to the assets folder in the Site Assets library of the root web, but the solution seems to keep running. Although the folder is not visible for the restricted user.

    I’m aware that sandbox solution has SC scope, but the manual deployment makes we wonder, if there is a workaround. Maybe a combination with a site feature could make sense? Deactivated by default, so site owner can decide if they want to use the functionality? Just thinking out loud.

    Best Regards
    Michael

    #1941

    Joe McShea
    Keymaster

    Hi Michael,

    So making this work with a web scoped feature in a sandbox solution is a non-starter in my opinion. The problem is due to the way you upgrade sandbox solutions. You first deactivate the solution, which deactivates the feature everywhere it’s been activated. Then upload the solution, and finally activate the solution.

    What comes next is the problem. If the feature is site collection scoped, SharePoint automatically activates it when the solution is activated. But if it’s web scoped, it does not, and in fact there is no way to determine where it was activated before the upgrade at this point.

    So say I have a site collection with 100 subsites, 50 of which are using SPEasyForms. I deactivate, upgrade, and then what. I have to know all 50 sites that are using it, visit them individually, and activate the web scoped feature. That’s a nightmare.

    Now as you suggest, the non-sandbox deployment mechanism is a different story. It wouldn’t be hard to modify that utility page to set user custom actions in the current web instead of the site collection. Then you’d just drop it in a library in any site where you wanted to use SPEasyForms, open it up, and click the install button, and voila. I do think this introduces a bit of a maintenance burden. In an environment with may collections and many more sites, it would be hard to tell where SPEasyForms is in use, and what version they’re using, etc. But if you’re willing to accept this burden, and feel strongly that SPEasyForms is too invasive for sites where it’s not being used, this is a viable option.

    Like I said, modifying the script would be easy, and I may do it at some point, but I’m pretty busy these days so I can’t promise when that might be. If someone doesn’t want to wait, is willing to take a crack at it, get’s it working, and wants to share, I’ll be happy to post their solution too.

    Joe

    • This reply was modified 2 months, 4 weeks ago by  Joe McShea.
    #1995

    Joe McShea
    Keymaster

    Hi Michael,

    I believe that a one line modification to SPEasyFormsInstaller.aspx could make it do what you want. I haven’t actually tested this, but I took a quick look at the code and I’ve copied in the modified function below, with a comment showing the modified line. Just make a copy of SPEasyFormsInstaller.aspx and replace the initClientContext method with the one below, and it should do what you want.

    initClientContext: function(success, failure) {
      if (!spEasyFormsInstaller.clientContext) {
        spEasyFormsInstaller.clientContext = new SP.ClientContext();
    
        if (!spEasyFormsInstaller.site) {
          // modified to get the current web instead of site
          spEasyFormsInstaller.site = spEasyFormsInstaller.clientContext.get_web();
        }
    
        if (!spEasyFormsInstaller.siteUserCustomActions) {
          // because site is actually web, this will now get the web user custom actions
          spEasyFormsInstaller.siteUserCustomActions = spEasyFormsInstaller.site.get_userCustomActions();
          spEasyFormsInstaller.clientContext.load(spEasyFormsInstaller.siteUserCustomActions);
          spEasyFormsInstaller.userCustomActions = spEasyFormsInstaller.siteUserCustomActions;
        }
    
        spEasyFormsInstaller.clientContext.executeQueryAsync(success, failure);
      } else if (!spEasyFormsInstaller.siteUserCustomActions) {
        spEasyFormsInstaller.siteUserCustomActions = spEasyFormsInstaller.site.get_userCustomActions();
        spEasyFormsInstaller.clientContext.load(spEasyFormsInstaller.siteUserCustomActions);
        spEasyFormsInstaller.userCustomActions = spEasyFormsInstaller.siteUserCustomActions;
    
        spEasyFormsInstaller.clientContext.executeQueryAsync(success, failure);
      } else {
        success();
      }
    },
    

    Joe

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

Scroll to top