How to move the Attachments field on a SharePoint new item form without using Power Apps

SharePoint enables us to collect information in ways beyond paper forms or even digitized Word or PDF forms. As we use it for more processes, you’re likely to run into situations where you wish for a higher level of customization but don’t want to go so far as using Power Apps for a simple need. One such need, as suggested by Jacqueline Vo on LinkedIn, was for moving the Attachments field on the default SharePoint form. And in this post, we’ll do just that.

Want to remove it altogether? Check out How to remove the attachments field from a SharePoint list’s new item form.

Introduction

By default, the attachments field is always at the bottom of the SharePoint new item form. However, there may be cases where you want to move the attachments field up to improve the flow of data entry or consumption. For example, if you are creating a reimbursement request, you may want to enter the request title and description, upload receipts, and then describe the receipts and amounts after.

How to rearrange fields on the SharePoint new item form using JSON

  1. Click the New button in the SharePoint list where you want to move the attachments field up.
  2. Click the Edit form button in the upper right corner of the form.
  3. Click Configure layout.
Location of the new form’s Configure layout option | Click to enlarge
  1. Select Body from the dropdown menu and paste the JSON code (see below) into the JSON editor
The Configure layout panel for the form body section | Click to enlarge
  1. Replace the sample column names in the JSON code below with your own columns’ display names.
  2. Click Save.

Important: Copy + Paste, then update for your own column names

Replace the sample column names in the JSON code below with your own column names. Be sure to use the column’s display names (how they appear as column headers and field names on the form), not their internal names. If the display name of the column changes at some point, your JSON will need updated as well or mismatched columns will be placed at the bottom.

The following two sections will give you two examples of ways you can use this method to customize your form:

  • One basic, three-section form layout
  • One four-section form layout with section headers

Without Section Headers

Here is an example of the JSON code you might use to simply rearrange the fields on the form into three sections – particularly, in our example, the Attachments column into a middle section:

{
    "sections": [
        {
            "displayname": "",
            "fields": [
                "Title",
                "Description"
            ]
        },
        {
            "displayname": "",
            "fields": [
                "Attachments"
            ]
        },
        {
            "displayname": "",
            "fields": [
                "Category",
                "Priority",
                "Due Date"
            ]
        }
    ]
}

Here’s an example of how this code, with a few additional columns, might look. Notice I added an Images column in the same section so all “attachment-like” content is done in one spot on the form.

JSON-formatted SharePoint form with Attachments in a middle section | Click to enlarge

With Section Headers

Here is an example of the JSON code you might use to customize a SharePoint new item form that includes section headers to help break the form into four logical groupings. The main difference is the inclusion of a value (the heading) between the double quotes that follow "displayname":

{
    "sections": [
        {
            "displayname": "Trip description",
            "fields": [
                "Reason for travel",
                "Requester",
                "Destination",
                "Travel start date",
                "Travel end date"
            ]
        },
        {
            "displayname": "Documentation",
            "fields": [
                "Attachments"
            ]
        },
        {
            "displayname": "Airfare",
            "fields": [
                "Airline",
                "Estimated airfare"
            ]
        },
        {
            "displayname": "Hotel",
            "fields": [
                "Hotel",
                "Estimated hotel cost"
            ]
        }
    ]
}

Here’s a visual example of how this form might look. Notice the attachments field is now below the Trip description section, but above Airfare.

A customized form and its JSON formatting | Click to enlarge

Working with additional columns and sections

The examples provided above will get you started – but you may want more than three or four sections, or have fewer or more columns in your list. Here are some general tips for adjusting this code to suit your needs:

Basically, each additional column must:

  • Be inside double quotes
  • Be separated from the next column by a comma
  • The last column listed in a section doesn’t need a comma after its quotes

And each section must:

  • Start with "sections": [ { "displayname": "Optional section name", "fields": [
  • And end with ] }
  • Have a comma between each section’s code (except after the last one)

Also keep in mind that columns added later, or left out of the code, will be added to the bottom of your form automatically. Don’t forget to update your code to place it in the section you’d like.

Why do I need sections if I just want all fields in one?

If you’re not working with the Attachments column specifically, you can bypass the JSON code altogether and simply use the Edit columns feature to rearrange, show, and hide columns as you please. The attachments column will always appear last in this case.

But moving the Attachments field within the form requires that you place it in a section strategically. Simply listing it in a specific order all in one section will still place it at the bottom of your form as seen here. On the right, it’s listed in the code in the middle, but since it’s in the same section as all other fields, it still gets placed at the bottom due to the column ordering (Edit columns settings) taking precedence.

A single-section form demonstrating column order taking precedence over formatting | Click to enlarge

This is a good thing, really, because your want your JSON formatting to cooperate with the column ordering functionality for easier updates later. In other words, you and your colleagues can reorder, show, and hide columns as you normally would using the Edit columns option on the form and your JSON sections will still be respected. You’d simply be rearranging the fields within each respective section you set up in the code.

Edit columns option for adjusting column order and visibility | Click to enlarge

So, if you only want to move the Attachments column, consider an approach like the first example in this post: Section 1 is a few general fields, Section 2 is only Attachments, and Section 3 is the rest of the fields. Don’t use any headers, and your form will still feel like a single-sectioned form.

Conclusion

In conclusion, I have shown you how to move the attachments field up on a SharePoint new item form using JSON. This technique can be used to rearrange all of the columns on the form into as many, or as few, sections as you want. Just remember that you need at least three sections if you intend for Attachments to be somewhere in the middle. If you want to learn more about customizing SharePoint forms, check out Configure the list form | Microsoft Learn.

How to create one-click, direct download links in modern SharePoint Online libraries

I previously blogged how to create one-click direct download links, but that post was exclusive to the classic experience in SharePoint (or any opportunity in which we could use classic html/css).

Normally, to download a document in modern SharePoint Online libraries, we would have to use a file’s menu (right-click or ellipsis) then choose Download.

Click to enlarge

I was recently challenged to help figure out how to create a single click experience to immediately download a document in modern SharePoint Online libraries and after much trial and error was able to do so using a little bit of JSON in a calculated column.

Here’s how to create a Download link column in modern SharePoint libraries:

1. Create a calculated column (Library Settings > Create Column) named Download and set its formula to =””

Click to enlarge

2. Copy and paste the following JSON code into the JSON formatting field of the calculated column settings.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "txtContent": "Download",
  "attributes": {
    "target": "_blank",
    "href": "=@currentWeb+'/_layouts/15/download.aspx?sourceurl='+[$FileRef]"
  }
}

3. Set the new column to show in the default view so it’s visible in the library and click OK.

Click to enlarge

4. Return to your library, and test it out!

And if you want anonymous users to be able to use these convenient download links, be sure to share a FOLDER link with the anonymous user(s) so they will see the file in the library alongside the one-click download link.

Optional formatting of the Download link

And while I’m not a JSON expert, I did dabble a bit in stylizing the Download link so it would look a little bit better. You can add a little bit of style to the JSON to achieve a more button-like experience (or for the advanced among you, change the element to an actual button or download icon).

Here’s how you can get started stylizing the text link (see result at bottom):

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "txtContent": "Download",
  "style": {
    "background-color": "gray",
    "text-decoration": "none",
    "color": "white",
    "font-size": "14px",
    "padding-left": "5px"
  },
  "attributes": {
    "target": "_blank",
    "href": "=@currentWeb+'/_layouts/15/download.aspx?sourceurl='+[$FileRef]"
  }
}
Click to enlarge

Optional usage of the file’s name instead of “Download”

One small change to the JSON will reference the file’s name for the link instead of using “Download” for all links. Then you could hide Name and just use your Download column.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "txtContent": "[$FileLeafRef]",
  "attributes": {
    "target": "_blank",
    "href": "=@currentWeb+'/_layouts/15/download.aspx?sourceurl='+[$FileRef]"
  }
}
Click to enlarge

SharePoint conditional column formatting with JSON: Beginner, intermediate, and advanced background colors example

I borrowed from Microsoft’s documentation on conditional column formatting recently to modify a modern experience list in SharePoint 2019. This also works for SharePoint Online/O365, but will not work in classic experiences (or pre-2019 server versions). I modified Microsoft’s example on conditional background colors for a numeric range and created a similar conditional column formatting result for text values.

In this example, I have a list for upcoming training opportunities. There’s a column named “Level” which is a choice field of either Beginner, Intermediate, or Advanced. The JSON code at the bottom of this post changes the column’s background color value to green, yellow, or red respectively based on the level selection. Here’s a demonstration of the result:

Click to enlarge.

You could modify this code to suit your own column’s values/options, then paste it into the Column Formatting section of that column’s settings (List settings > Select column from Columns section). Do not change @currentField in the JSON code – that’s just a reference to whichever column you add it to and doesn’t need to be your column’s name.

Click to enlarge
{  
  "elmType": "div",  
  "txtContent": "@currentField",  
  "style": {  
    "color": "#fff",  
    "padding-left": "14px",  
    "background-color": {  
      "operator": "?",  
      "operands": [  
        {  
          "operator": "==",  
          "operands": [  
            "@currentField",  
            "Beginner"  
          ]  
        },  
        "#2ECC71",  
        {  
          "operator": "?",  
          "operands": [  
            {  
              "operator": "==",  
              "operands": [  
                "@currentField",  
                "Advanced"  
              ]  
            },  
            "#E74C3C",  
            {  
              "operator": "?",  
              "operands": [  
                {  
                  "operator": "==",  
                  "operands": [  
                    "@currentField",  
                    "Intermediate"  
                  ]  
                },  
                "#F1C40F",""
              ]  
            }  
          ]  
        }  
      ]  
    }  
  }  
}