Hey there
Weâre back once,
Weâre back twice,
Weâre back until the iterator stops
Yep, thatâs right, last week we released an iterator action in the no-code workflows.
We also:
- added filters between actions in the workflows,
- fixed a super annoying bug on the select element,
- updated the Chart.js plugin , itâs soooo easy to use now,
- added a workflow action to download an array in CSV format , and
- removed the lookup depth option when you setup an Airtable collection (weâll explain why below).
Using For Loops in No-Code Workflows
There is a new action in the workflows: the Iterator.
Also called a âFor Loopâ
This allows you to loop through an array of items and do something with every item in the list.
For example, letâs say you want to let users type in cities they would like to visit and display those cities on a map.
However, Googleâs Maps Javascript API expects longitude and latitude coordinates. It canât locate the city with a simple name.
In that case, to display the cities on the Map element in WeWeb, you would need to loop through the list of cities typed in by the user and get the coordinates from another API.
Hereâs one way you could do it
Step 1 â Create an Array variable with the city names
When a user types in a city name, add it to the list.
Step 2 â Loop through the list of city names
Keep in mind that the Iterator expects an array, even if thereâs only one item in the array:
Step 3 â Get the latitude and longitude of each city
To get the coordinates of each city, we used the OpenCageData API because it accepts client-side requests.
Spoiler alert: youâll soon be able to make server-side requests in WeWeb as well. Stay tuned
In the screenshot below, you can see:
- we pasted the URL to get the coordinates of city names,
- we bound the query (âqâ) to the item in our list of cities that is currently being looped through,
- we added our API key to the âkeyâ key â thatâs a mouthful! , and
- set a limit of 1 result per city name so Paris doesnât return Paris, Texas for example.
Step 4 â Create an Array variable with the city coordinates
Here, we are adding the results from action 3 to an Array variable named âcoordinatesâ:
Step 5 â Stop Iterator
Finally, you can add an action to stop the Iterator:
Step 6 â Trigger the Workflow on Page Load
Once youâve setup this workflow, you can trigger it On Page Load:
Step 7 â Bind the results in the coordinates variable to the Map element
Back on the Map element, you can bind the markers to the âresultsâ in the âcoordinatesâ variable and bind the markers fields to the correct paths:
The reason we are binding to the âresultsâ is because thatâs where the API weâre using is putting the information we need (i.e. the latitude and longitude coordinates).
If youâre using a different API, keep in mind you need to bind the markers to the data that stores the values for the name, latitude, and longitude fields.
Ok then, next item on the agenda this week.
Lookup Depth
Itâs done. You can no longer add a lookup depth to an Airtable Collection in WeWeb.
Wait wait wait, itâs a good thing! Promise
Before
- Users added an Airtable Collection with lookup depth,
- They reached their data limit real fast, and
- Loaded tons of unnecessary data on pages that didnât necessarily need it.
The result: heavy pages that performed poorly.
Now
- Users add one Airtable Collection for each table in their base,
- They understand exactly which tables are taking up space,
- Depending on the data they need on a page, they only load that information,
- If they need to link two tables, they use the lookup, lookupArray, or rollup formulas to get the information they need from another Collection.
The result: lighter pages that perform much better with only the relevant data loaded onto the page
No-Code Charts
Assuming you have added the Chart plugin in the âPluginsâ menu, you can drag and drop a chart template on the Canvas from the âAdd menuâ:
Now, those elements have two settings: âGuidedâ and âAdvancedâ.
To use the âAdvancedâ mode, we recommend you read the Chart.js documentation to understand what data the library expects.
Otherwise, you can try out our brand new âGuidedâ mode. You will be invited to bind an array and choose what field you want as your X axis (horizontal):
Pro Tip
Binding the Y axis (vertical) is optional. By default, it will count the number of categories on the X axis.
Download CSV Action
In the âPluginsâ > âToolsâ menu, you can now add the Download data as CSV plugin:
When you add this to your WeWeb project, you will unlock access to the âDownload data as CSVâ Action in Workflows:
Warning
The âDataâ field in the âDownload data as CSVâ Action expects an Array of items, even if thereâs only one item in the list.
Ok then, thatâs it for now.
Weâll be back (very) soon with two new exciting announcementsâŚ
Until then, have a great week!