How to add an “Attachments” button on a SharePoint form without using Infopath

Why traditional SharePoint form design and not InfoPath?

For a very long time Infopath has been hailed as one of the better ways to develop SharePoint forms. It’s undeniable that InfoPath is fast, in many ways flexible and easy for more technical business users to maintain.

All of that said in 2014 Microsoft dropped the following bombshell:

The InfoPath 2013 application remains the last version to be released and will work with SharePoint Server 2016.

Source: Official MSDN blog entry.

As it appears InfoPath is nearing the end of its life we’ve begun developing SharePoint forms in a more traditional manner. We’ve used SharePoint 2013’s web compatibility to its fullest by using JavaScript for most of our interactions and ASP where needed. The outcomes have been very, very surprising. We’ve found we can do far more than we ever could with InfoPath. Forms are responsive making them mobile compatible (using our own CSS), adaptive to what the user enters and they look amazing.

One thing we have found is that users are still used to having an attachments button on their forms and haven’t adapted well to having to go to the ribbon to add attachments. As a reminder, this is the field that InfoPath would add to your SharePoint forms to allow users to easily add attachments:

SharePoint and InfoPath Attach file button

How do I add an attachments button to a traditional SharePoint form?

To add the attachments button to a traditional SharePoint form first open the library in SharePoint designer. For whatever reason SharePoint locks down the default ASPX form (typically titled NewForm.aspx) and creating a new one (and making it the default) will allow you to customize your form as you desire.

Once you have created a new form add the following to the page to add an equivalent button that duplicates the functionality of InfoPath:

This will present a basic button to attach files to your form. If you wish to further customize this to also list the attached files below it, the following should be used:

The final outcome will look something like the following (depending on how you adapt it for your own forms):

SharePoint Attach File Form Button

How to download files from a SharePoint Online Document Library

As SharePoint Online captures more and more market share people are going to start doing more and more with it.

One of the core challenges that I’m noticing is the struggle for developers in transitioning from server side code to using the client side object model (CSOM). There are a lot of ways to accomplish and this is just one example in many. This example assumes that the source document library has a column called Status. It will download files from that document library where the Status is equal to New and after download all of these files it will then update the status of those files to Downloaded.

SharePoint deployment scope, solution and features

SharePoint Features

SharePoint Features can be scoped to the Farm, Web Application, Site Collection, and Web Site level depending on the purpose of the feature. The Feature scope is determined by the setting of the Scope attribute in the Feature element defined in the feature.xml file.

A sample Feature element tag is given below:

<Feature Id="F62C96CF-79FD-44be-8882-E9BFBD199184">
Title="Feature Title"
Description="Feature Description"
Version="1.0.0.0"
Scope="Site"
Hidden="false";
</Feature>

Web Site scoped Feature (Scope=”Web”):

A Web Site scoped Feature is one that can be activated only at the individual Web site level. List templates, list instances, custom actions, event receivers, etc are the some common elements for web site scoped features. Web Site scoped features can be activated by using:

Run the following STSADM command:

Site Collection scoped Feature (Scope=”Site”):

A Site Collection scoped Feature is one that can be activated at the site collection level and contains items that apply to the site collection as a whole (for example, content types that are shared across the site collection), as well as items that can be activated per site (for example, list instances, etc). Site Collection scoped features can be activated by:

Run the following STSADM command:

Web Application scoped Feature (Scope=”WebApplication”):

A Web Application scoped Feature is one that can be activated at the web application level and contains items like administrative web application links, delegate control registrations, feature/site template association, document form registrations, etc. A farm Feature can contain, for example, links to /_layouts pages and files, /_admin pages, and other elements. Web Applicationscoped features can be activated by using:

Run the following STSADM command:

Farm scoped Feature (Scope=”Farm”):

A Farm scoped Feature can be activated at the server farm level. A farm Feature contains a number of elements that are critical for implementing applications and logic anywhere within a deployment. A farm Feature can contain, for example, links to /_layouts pages and files, /_admin pages, and other elements. Farm scoped features can be activated by using:

Run the following STSADM command:

SharePoint Solutions

SharePoint solutions are either deployed globally or targeted to a particular web application. The decision of which is made automatically by the SharePoint Solution framework depending on the contents of the solution manifest. Exception to this rule are Sandbox solutions which are managed on the site collection level.

Globally Deployed Solutions

When a solution is deployed globally, the assembly DLL file will go and sit under windows\assembly folder. All SharePoint application pools, including Central Administration’s, are recycled automatically. This can be good and bad. This is good because any GAC installed DLL that has been upgraded needs to be reloaded. This can be bad though with regards to the availability of your entire SharePoint Farm.

Web Application Targeted Solutions

When a web application targeted solution is deployed or retracted, the assembly DLL file will go and sit under the inetpub\websitename\bin folder. Only the application pools of the targeted web applications are recycled. When deploying and retracting a web application targeted solution, deploy or retract it only to those web applications that will use it … thus preventing unnecessary recycling of application pools.

Sandbox Solutions

Sandbox solutions are deployed to the site collection. This new mechanism has been introduced in SharePoint 2010 to provided more isolation between deployed components. Sandbox Solutions deployment does not require application pool recycle and does not allow deploying DLLs into the GAC, as everything is stored in content database where site collection resides. These solution also provide much more restrictive execution model and limited access to SharePoint API.

PowerShell Code to deploy solutions (WSP)

PowerShell to deploy the WSP to the GAC on server and deploy to all URLS

PowerShell to deploy the WSP to the GAC on server and deploy only to 1 specific web application (not in bin folder)

PowerShell to deploy to specific webapplication at bin folder on server

PowerShell to deploy to all the webapplication at their bin folders on server