How to Use Global Variables in Latenode for Efficient Data Tracking

Using Global Variables Across Different Scenarios in Latenode

Welcome to this tutorial on using global variables in Latenode. Today, we will uncover a clever workaround that allows you to capture and process data effectively over time. For demonstration, we will use the example of tracking temperature throughout the day.

Scenario One: Getting and Writing Three Global Variables

Imagine you want to monitor the temperature in London throughout the day. Here’s how you can achieve this:

First, our scenario begins with a trigger node that can be activated manually. This node serves as the starting point of the workflow.

Next, we incorporate an HTTP request node which fetches the current temperature from a weather service. This node ensures we have real-time temperature data at our disposal.

The most crucial part takes place in the JavaScript node, which determines the time of day: morning, afternoon, or night, based on the current hour. Depending on the time you run the scenario, it will follow one of three possible routes. Each route leads to a set of global variables nodes which save the temperature data as either morningTemp, dayTemp, or nightTemp. This method allows us to capture different temperature readings at various times throughout the day.

Scenario Two: Processing Global Variables

Now, let’s move to the second scenario—processing the global variables we've stored.

This scenario also starts with a manual trigger, ensuring we can initiate the process at our discretion.

The real magic happens in the JavaScript node, where we retrieve the saved temperature variables. The script converts the temperatures from Kelvin to Celsius and calculates the daily average. This step is crucial for getting meaningful insights from our data.

Finally, a webhook response node displays our result. This node gives us a clear view of the average temperature for the day in a user-friendly format.

Practical Applications of This Technique

By using this two-scenario approach, we’ve created a straightforward yet effective temperature tracking system. You can run the first scenario multiple times a day to gather data, then employ the second scenario to calculate your daily average.

While we focused on weather data, this technique is not strictly limited to that. You could use similar methods to:

- Track stock prices

- Monitor website traffic

- Log any changing data over time

The potential applications are vast, making this technique incredibly versatile.

That's all for today. We hope this tutorial has sparked some ideas for your own projects. Happy automating!

Other Videos