Custom Action – Farm/WebApplication Scope

In our recent SP2013 project, we need to add a new item under Welcome Control to allow users sign in as different users.

We used VS2012 to create a Farm solution and add a Module to update welcome control. Unfortunately, this item was added twice since we deploy it with a Site level feature, and there will be more than one site collections, so we tried to move this to a WebApplication level feature. Sadly, we cannot find it in the left column “Items in the solution” of this WebApplication Feature design mode.

After some researches, we realized that Modules are not supported at the Farm and WebApplication scope, so we have to use Empty Element to make this custom action deployed to WebApplication level.

<ProjectItem Type="Microsoft.VisualStudio.SharePoint.Module" DefaultFile="Elements.xml" SupportedTrustLevels="All" SupportedDeploymentScopes="Web, Site" xmlns="">
    <ProjectItemFile Source="Elements.xml" Target="WelcomeControlUpdate\" Type="ElementManifest" />

Note: It won’t help even you change SupportedDeploymentScopes to WebApplication level. Visual Studio does not recognize  the change. 

Create an Empty Element instead Module will solve this issue:

<ProjectItem Type="Microsoft.VisualStudio.SharePoint.GenericElement" DefaultFile="Elements.xml" SupportedTrustLevels="All" SupportedDeploymentScopes="Web, Site, WebApplication, Farm, Package" xmlns="">
    <ProjectItemFile Source="Elements.xml" Target="UpdateWelcomeControl\" Type="ElementManifest" />

<Elements xmlns="">
  <CustomAction Id="WelcomeSwitchUser"
                Location="Microsoft.SharePoint.StandardMenu" Sequence="10001" 
                Title="Sign in as Different User" Description="Login with a different user.">
          <UrlAction Url="~site/_layouts/AccessDenied.aspx?loginasanotheruser=true" />

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s