N8N Automations – Part 1: Detecting Changes in a Spreadsheet on a OneDrive Folder

JTS

I’ve been experimenting with N8N lately, and honestly, it’s starting to feel like one of the most overlooked tools for basic business automations.

While it’s marketed as a no-code platform, having a background in coding really helps. Many of the more advanced workflows require some comfort with JavaScript and JSON. ChatGPT can definitely help write snippets or logic, but it’s worth noting that much of the training data is based on older versions of N8N, which means you’ll sometimes need to go old-school and Google around for updated answers.

Article content

Connecting to external systems like Microsoft OneDrive can also be tricky. Setting up Azure permissions for OneDrive access was time-consuming, and to make it more interesting, the authentication process is different between OneDrive Personal and OneDrive Business. The business version is much easier to integrate, but my workflow used the personal edition, which required extra digging.

On the other hand, integrating Trello was refreshingly straightforward. Once I installed a browser extension to view Trello board IDs (available at https://trello.com/power-ups/), everything worked smoothly and ChatGPT’s guidance was spot on there.

This is the first of two automation examples I’ve built that could be useful in an office environment.

  • Part 1 (this post): Detects when a spreadsheet changes in a OneDrive folder and updates another spreadsheet.
  • Part 2 (next post): Monitors a Trello board and automatically emails the team when projects are overdue.

I’m using the self-hosted community version of N8N, which means no ongoing software cost, another major benefit of the platform.

Use Case: Updating One Spreadsheet When Another Changes

One of the most practical use cases for N8N is monitoring a OneDrive folder and taking action when a file changes. For teams that work heavily in spreadsheets, this can automate notifications or trigger updates when data changes.

In my case, I wanted to detect when a specific spreadsheet was modified, read a particular cell value, update another spreadsheet with that value, and send an email alert.

Step 1: Scheduling the Workflow

Start with a Schedule Trigger node. I set mine to run every minute. Tip: avoid running it every few seconds, as Microsoft may temporarily block your account for excessive API calls.

Article content

Step 2: Listing Files in the Target Folder

Use an HTTP Request node to call the OneDrive API and list files in the folder you want to monitor: https://graph.microsoft.com/v1.0/me/drive/items/<YOURFOLDERID>/children

The folder ID is easy to find in OneDrive Business, but for OneDrive Personal, you’ll need to use an additional HTTP call to locate it.

Article content

Step 3: Finding the Target File

Add a Code Node with a simple JavaScript snippet to find your file, in this case finance_input.xlsx:

const files = $json.value;
const file = files.find(f => f.name === 'finance_input.xlsx');
return file ? [file] : [];
Article content

Step 4: Detecting Changes

This was the trickiest part. The goal was to compare the file’s last modified timestamp to a stored value from the previous run.

Here’s the working version of the script:

const data = $getWorkflowStaticData('global');
const currentModified = new Date($json.lastModifiedDateTime).getTime();
const lastModified = data.lastModified || 0;
data.lastModified = currentModified;

return {
  json: {
    changed: currentModified > lastModified,
    id: $json.id,
    name: $json.name,
    lastModified: $json.lastModifiedDateTime
  }
}; 

This works great, but only in production mode. During testing, N8N won’t persist that static data. Hopefully, the N8N team addresses that limitation soon.

Step 5: Checking for Changes

An IF Node checks if the “changed” flag is true. This might seem redundant, but it gives flexibility if you want to add logic later for when no changes occur.

Article content

Step 6: Reading a Cell Value

If the file has changed, use another HTTP Request to read a specific cell from the spreadsheet. Microsoft’s Graph API supports this:

https://graph.microsoft.com/v1.0/me/drive/items/{{$json[“id”]}}/workbook/worksheets/Sheet1/range(address=’C1′)

This grabs the value from cell C1 in finance_input.xlsx.

Article content

Step 7: Updating Another Spreadsheet

Now, take that value and update another spreadsheet using a PATCH request to its endpoint:

https://graph.microsoft.com/v1.0/me/drive/items/TARGETFILEID/workbook/worksheets/Sheet1/range(address=’C1′)

You’ll need to find the target file’s ID, but once set, the update is seamless.

Article content
Part 1
Article content
Part 2

Step 8: Sending a Notification

Finally, send a notification. I used a simple Send Email node, but you could just as easily integrate with Slack, Teams, or another system supported by N8N.

Article content

Wrap-Up

This workflow isn’t the simplest, but it’s powerful. In just seven steps, you can build a self-hosted automation that monitors changes, updates other data sources, and notifies your team automatically.

N8N has its quirks such as documentation gaps, API differences between OneDrive editions, and the production-only variable persistence, but it’s a remarkably flexible platform for business automation.

As the tool matures, I expect these processes will only get smoother. Until then, it’s a great playground for anyone looking to streamline repetitive business workflows without paying for expensive SaaS automation tools.

About the author

During his twenty-five professional years, Mr. Silva has had experience in nearly every facet of the Information Technology industry. Ranging from advanced data mining / data visualization systems to running multi-state small business IT infrastructures, Mr. Silva has always provided precise and cost-effective strategies to meet any client’s needs. With his tremendous work ethic and “Can-Do” attitude, Mr. Silva has always met every challenge head-on and with intelligent determination. Mr. Silva is also a certified NAUI Advanced/Nitrox Diver, hoping to get a few more wrecks under his belt in the Atlantic.