5

I want to add Users Custom Action on web application level which will be found on all Site Collection including newly created Site Collection.

I have tried to add Users Custom Action on Site Collection Level and it will automatically added on each sub-sites.

But How can I add Users Custom Action to Web Application Level so which will be added on each Site Collection and each sub-site of it including newly created Site Collection and sub-sites.

FYI :- I want to add Users Custom Action programmatically using c#.

1 Answer 1

2

Simple, if you're deploying WSP solution packages. Then you can just create, deploy and activate a web application scoped feature using the feature.xml outlined below. Define your custom actions in the CustomActions.xml file.

<?xml version="1.0" encoding="utf-8"?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/" 
         Id="{5F377DB6-FDC8-477C-9423-4B16C5FAB505}" 
         Scope="WebApplication"
         Version="1.0.0.0"
         Title="Feature Title" 
         Description="Feature Description">
    <ElementManifests>
        <ElementManifest Location="CustomActions.xml" />
    </ElementManifests>
</Feature>

Server side deployments are no longer recommended for new applications. Hence, you should also consider these options for deploying your custom actions:

  • Create and deploy a SharePoint App that registers the custom actions. The app can be deployed to a site collection or globally through the App Catalog site.
  • Use PowerShell scripting to deploy the custom action(s) to all applicable site collections. Leverage the Add-PnPCustomAction cmdlet from SharePoint Patterns and Practices (PnP).

The PnP PowerShell can run remote, works with SharePoint online and on-premises. I recommend this option the most.

3
  • I don't want to do it with PowerShell. Is It possible through code? Console application or Windows desktop Application. Aug 3, 2017 at 9:51
  • Yes, you can indeed write your own code to do it! That's an equally good approach. Using the CSOM, you'll need to add your actions to the Site.UserCustomActions collection. For example with c# as demonstrated in this article: andrewwburns.com/2013/12/01/… Aug 3, 2017 at 10:31
  • Yes, Exactly i am doing like this only. But I am not able to add it on newly created Site Collection. I can add the custom action on sub-sites if I added the custom action on site collection level. In the Same way I want this to happen for Site Collection. Aug 3, 2017 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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