A lesson is completed when you tick it, when you watch its video to the end or when you score 80% on its quiz. The certificate is issued online after the final assessment, from a score of 32 out of 40.
Lesson 16, module 4: The building blocks of a flow Dates, amounts, names and addresses: reformatting data along the way Why does the 9:14 request show up as 8:14 in the spreadsheet?
Data arrives messy: the flow cleans it up along the way. [Diagram: The same request, raw then clean] What the form sends What the spreadsheet receives Four kinds of trap always come back. Dates in universal time Amounts written as text Messy names and phone numbers Zeros dropped by the spreadsheet An expression converts the date to Paris time. Prompt: {{ DateTime.fromISO($json.createdAt).setZone('Europe/Paris').toFormat('dd/MM/yyyy HH:mm') }} Response: 2026-11-10T08:14:22.000Z becomes 10/11/2026 09:14: the time the customer actually sent her request. Reformatting is done once, right after the trigger. [Diagram: Reformat before writing] 1. Raw value 2. Request node 3. Clean value 4. Check 5. Writing Reformatting goes right after the trigger, once for all the actions. An unreadable value stays empty and gets flagged, never guessed. [Diagram: What the flow does with a value] Green: Safe correction Orange: Value left empty and flagged Red: Never done by the flow Correct what's certain, flag what isn't, never make things up. An AI has no business reformatting a date. A function: free and predictable An AI: costly and variable AI helps write the expression In the exercise, you clean up the export from an old invoicing tool.
Your turn: The export from an old invoicing tool The written lesson, the corrected exercise and the quiz are below the video.
Lesson 16 of 50 · module 4, the building blocks of a workflow
Dates, amounts, names and addresses: reformatting data along the way
Data rarely arrives in the right format: dates in universal time, amounts written as text, names in capitals, phone numbers in +33. The flow reformats them straight after the trigger, with date, number and text functions, in Paris time. Anything unreadable stays empty and is flagged, never guessed.
24 min of reading
1 min 54 of video
6 diagrams
1 demande to copy
3 exemples pratiques
4 exercices answerss
5 questions
1 ressource
By the end of this lesson, you will know how to
Convert a date received in universal time into a Paris date and time, in DD/MM/YYYY format
Turn an amount written as text into a number, and a name, phone number or postcode into a clean value
Decide for each field what gets fixed, what gets flagged and what is never guessed
What’s covered
Dates and time zones
Amounts, from text to number
Names, phone numbers and postcodes
The same job in Make and in Zapier
A function, not an AI
3 worked examples, followed from start to finish
Exercise with answers · The export from an old invoicing package
3 practice exercises, from guided to demanding cases
The quiz
Key points
The reformatting happens in the flow, straight after the trigger, once for all actions.
A date received in universal time is converted to the Europe/Paris time zone before being written in DD/MM/YYYY format.
An amount becomes a number only if it is clean; otherwise the cell stays empty and the request is flagged.
Postcodes and phone numbers are text: write them as such to keep the leading zero.
A function reformats, an AI writes the expression: never hand an AI the conversion of each value.
In the Pessac joinery’s spreadsheet, a request sent at 9:14am appears at 8:14am, one name arrives in lower case, another in capitals, the phone numbers mix 06, +33 and full stops, and the Budget column contains “15 000 €”, “8000” and “entre 8 et 10k”. None of this matters while Sandrine fixes it by hand. It all matters once the flow sorts, calculates a follow-up date or compares a budget: dirty data leads to a wrong decision. So the reformatting happens in the flow, once, straight after the trigger.
The same request, raw then clean
What the form sends
Received 2026-11-10T08:14:22.000Z
Surname: martin
First name: JEAN-PIERRE
Phone: +33 6 12 34 56 78
Budget: €15,000
What the spreadsheet receives
Received 10/11/2026 09:14
Surname: MARTIN
First name: Jean-Pierre
Phone: 06 12 34 56 78
Budget (€): 15000
Dates and time zones
Applications exchange dates in ISO 8601 format, in universal time: 2026-11-10T08:14:22.000Z, where the Z means UTC. In November, Paris is one hour ahead of UTC; in July, two. An ISO date written as is into a spreadsheet is therefore one or two hours out, and unreadable for a human. You need to convert it to the Europe/Paris time zone, then write it in French format. In n8n, Luxon is the recommended date library: DateTime.fromISO() reads an ISO date, DateTime.fromFormat() reads a date written another way, setZone() changes the time zone, $now and $today give the present moment and today at midnight.
The most useful format tokens (case matters: in Luxon, MM is the month and mm the minutes)
What you want
Luxon (n8n)
Make
Result
French date
dd/MM/yyyy
DD/MM/YYYY
10/11/2026
Date and time
dd/MM/yyyy HH:mm
DD/MM/YYYY HH:mm
10/11/2026 09:14
Sortable date
yyyy-MM-dd
YYYY-MM-DD
2026-11-10
Amounts, from text to number
A budget entered by a customer is text: “15 000 €”, “1.250,50”, “8000”. To compare it with a threshold or add it up, you need a number, written the US way for the machine: 15000, 1250.5. The course rule is simple: remove what is certain (spaces, the € symbol, thousands full stops), convert the decimal comma, and leave empty anything that is not a clean number. “Entre 8 et 10k” does not become 9,000: it becomes empty, and Sandrine reads it.
The indicative budget as a number, or emptyJavaScript
{{ (() => {
// 1. retirer les espaces (y compris insécables) et le symbole €
const brut = String($json['Budget indicatif'] || '').replace(/[\s€]/g, '');
// 2. retirer les points des milliers (1.250,50) puis passer la virgule en point
const propre = brut.replace(/\.(?=\d{3}(\D|$))/g, '').replace(',', '.');
// 3. un nombre propre, sinon vide : jamais deviné
return /^\d+(\.\d+)?$/.test(propre) ? Number(propre) : null;
})() }}
Tested on “15 000 €” (15000), “1.250,50” (1250.5), “12 500,00 €” (12500), “10k” and “entre 5000 et 8000” (empty). Replace $json['Budget indicatif'] with the field dragged from INPUT.
Names, phone numbers and postcodes
Text functions do most of the work: trim() removes spaces at the start and end, toUpperCase() and toLowerCase() change the case, and replace() with a regular expression removes or replaces characters. n8n adds its own functions, such as toTitleCase() (capital letter for each word, short linking words left in lower case), extractEmail() and isEmail(). For a compound first name such as Jean-Pierre or Marie-Ève, a regular expression that adds a capital after each space, hyphen or apostrophe is safer.
The Request node from the lesson on triggers becomes the place where reformatting happens: each field of the “Edit Fields (Set)” node gets an expression instead of a simple dragged-in value. The block below gives the expression for each field; paste each one into the field of the same name, in expression mode.
The Request node fields, reformattedJavaScript
// recue_le : date d'envoi, heure de Paris
{{ DateTime.fromISO($json.createdAt).setZone('Europe/Paris').toFormat('dd/MM/yyyy HH:mm') }}
// nom : sans espaces en bord, en majuscules
{{ String($json['Nom'] || '').trim().toUpperCase() }}
// prenom : majuscule après chaque espace, tiret ou apostrophe
{{ String($json['Prénom'] || '').trim().toLowerCase().replace(/(^|[\s'-])\p{L}/gu, c => c.toUpperCase()) }}
// courriel : en minuscules
{{ String($json['Courriel'] || '').trim().toLowerCase() }}
// telephone : 06 12 34 56 78, ou vide si le numéro n'a pas 10 chiffres
{{ (() => { const c = String($json['Téléphone'] || '').replace(/\D/g, '').replace(/^(00)?33/, '0'); return /^0\d{9}$/.test(c) ? c.replace(/(\d{2})(?=\d)/g, '$1 ') : null; })() }}
// code_postal : texte à 5 chiffres, zéro initial gardé
{{ String($json['Code postal'] || '').replace(/\s/g, '').padStart(5, '0') }}
// date_souhaitee : la date ISO du formulaire au format français
{{ $json['Date souhaitée'] ? DateTime.fromISO($json['Date souhaitée']).toFormat('dd/MM/yyyy') : null }}
Replace the names in square brackets ($json['Téléphone']…) with the fields dragged from INPUT: their exact name depends on the trigger's output.Reformat in the n8n Demande node
Open the workflow settings (menu at the top right of the editor) and choose the Europe/Paris time zone.
Open the “Edit Fields (Set)” node named Demande, just after the trigger.
For each field, switch the value to expression mode and paste the expression from the block above.
Choose the field type: String for the name and phone number, Number for the budget.
Click “Execute step”: the OUTPUT panel shows the clean value of each field.
Pin the trigger output (“Pin data”) and replay with ten real, anonymised requests, one at a time.
In the Google Sheets node, set “Cell Format” to “Let n8n format” so the spreadsheet does not reinterpret the values.
Edit Fields: one expression per field, tested on real values.
3Clean value
“06 12 34 56 78”, “10/11/2026 09:14”, 15000 as a number.
4Inspection
An unreadable value becomes empty and the request is flagged, never guessed.
5Writing
The spreadsheet row and the message use the clean values.
The reformatting goes straight after the trigger, once for all actions.
The same job in Make and in Zapier
Reformatting tools
Need
n8n
Make
Zapier
ISO date to DD/MM/YYYY, Paris time
DateTime.fromISO(…).setZone('Europe/Paris').toFormat('dd/MM/yyyy HH:mm'), or the Date & Time node “Format a Date”
formatDate(date; DD/MM/YYYY HH:mm; Europe/Paris)
Formatter, Date / Time, specifying the source format
Read a date written the French way
DateTime.fromFormat(texte, 'dd/MM/yyyy')
parseDate(texte; DD/MM/YYYY)
Formatter, Date / Time, source format specified
Add days
plus({ days: 7 }) en Luxon, ou nœud Date & Time « Add to a Date »
addDays(date; 7)
Formatter, Date / Time
Upper case, lower case
toUpperCase(), toLowerCase(), toTitleCase()
upper(), lower(), capitalize(), startcase()
Formatter, Text
Remove or replace characters
replace() with a regular expression, trim()
replace(texte; /motif/g; remplacement), trim()
Formatter, Text
Phone
Regular expression above
replace() with /\D/g, then splitting
Formatter, Numbers, phone number format: choose France, as the default country is the United States
Formatter by Zapier requires a paid plan and does not count towards tasks. How it behaves when it fails is worth knowing: an unreadable date gives “now”, the moment the Zap runs; an invalid phone number comes out unchanged; a number that cannot be formatted comes out as is. In other words, Formatter does not warn you: add a filter or a check after it for the fields that matter.
What the flow does with a value
Safe fix
Extra spaces, capitals
+33 replaced by 0
ISO date converted to Paris time
Value left empty and flagged
Budget “between 8 and 10k”
9-digit phone number
Date “end of March”
Never done by the flow
Guess an amount
Complete a number
Choose a date on the customer���s behalf
Fix what is certain, flag what is not, never make anything up.
A function, not an AI
A firm opinion: AI has no place in reformatting a date, an amount or a phone number. A function is free, instant and always gives the same result; an AI costs money on every call, sends the data to a provider and can, once in a hundred times, swap day and month. AI is, however, excellent for writing the expression and suggesting test cases, once, while you build. It becomes useful again when you need to extract information from free text, which is covered in the lesson “Classify and extract with structured JSON output”.
Get a reformatting expression written and tested
Role: you are a developer who knows [n8n / Make] expressions.
Context: a form field contains values like these, copied as they are: [paste ten real anonymised values].
Task: write the expression that turns them into [desired format, for example “phone number in the format 06 12 34 56 78”]. Any value that cannot be transformed with certainty must give an empty value, never a guessed one.
Format: the expression, ready to paste, then an Original value | Expected result table for my ten values, then the list of cases the expression cannot handle.
Roughly what you should get
An expression of one or a few lines, a table showing the result for each of your ten values, with empty cells for unreadable values, and two or three edge cases flagged, such as a foreign number or an empty field.
Don't take the table at its word: paste the expression into the tool and check the result on your ten values.
“Log quote requests” sheet, Data box completed
Box
What is written
Trigger
New response to the Tally form “Demande de devis” (instant).
Data
Received: DD/MM/YYYY HH:mm, Paris time. Surname in capitals, first name with initial capitals. Phone 06 12 34 56 78 or empty. Postcode as 5-digit text. Budget as a number or empty. Preferred date DD/MM/YYYY. Personal data: yes.
Decisions
Unreadable value: empty, with a “To check” note in the message to Sandrine. The zone and routing remain those set by the filters and routers.
Actions
Spreadsheet row with the clean values (“Cell Format” set to “Let n8n format”); Teams message. Account: devis@.
Inspection
Green. Ten real anonymised requests replayed every time the expressions are changed. Backup: Thierry.
Mistakes to avoid
Writing the received ISO date into the spreadsheet as is, or converting it without a time zone.
The date is in universal time: one hour out in winter, two in summer, and a change of day for any request sent late in the evening. Follow-ups and date sorting become wrong.
Convert with setZone('Europe/Paris') in n8n or the time zone parameter of formatDate in Make, and set Europe/Paris in the workflow settings.
Copying a date format from one tool to another, for example DD/MM/YYYY in an n8n Luxon expression.
Tokens are not read the same way: in Luxon, DD and YYYY do not mean day and year as they do in Make. The date produced is wrong, with no error message.
Keep each tool’s token table to hand and test every format on a date where the day is above 12.
Letting the spreadsheet interpret postcodes and phone numbers.
01000 becomes 1000, 0612345678 becomes 612345678: the data is damaged as soon as it’s written, and the next flow that reads it gets it wrong.
Format the columns as Text, set “Cell Format” to “Let n8n format” in n8n, and write the phone number with its spaces.
Guessing an unreadable value so the cell isn’t left empty: 9,000 for “between 8 and 10k”, a 0 added to a 9-digit number.
An invented value looks real: nobody checks it, and it ends up in a quote, a follow-up or a statistic.
Leave the cell empty, keep the original value in the description or message, and flag the request to the person handling it.
3 SME situations followed from start to finish: the prompts exactly as they were written, the model answer to aim for, and what was checked before sending.
Example 1
The American dates of an estate agency in Pau
Pauline is an assistant at a five-person estate agency in Pau. Every month, she prepares a statement of mandates for property owners from the transaction software's export, which writes dates in US format (11/03/2026 for 3 November) and prices with thousands commas (245,000.00). The agency uses Make.
From the export to the owners’ table
1Export
Dates MM/DD/YYYY, prices 245,000.00.
2parseDate then formatDate
The date read the American way, written the French way.
3replace
Thousands commas removed.
4Table
Dates DD/MM/YYYY, prices as numbers.
Request 1
Make, for the Mandate date column: formatDate(parseDate(Date du mandat; MM/DD/YYYY); DD/MM/YYYY)
Tested on three rows of the export.
Pauline checks the second row: 02/28 can only be US format, proof that the whole export is. She notes in the sheet that the source format is set by the software and does not change from one row to the next.
Request 2
For the Price column: replace(Prix; /,/g; ), with the third argument left empty to remove the thousands commas, then written to a number-format column in Google Sheets.
Model answer
245,000.00 becomes 245000.00, displayed as 245 000,00 by the spreadsheet set to French.
The export’s decimal separator is the full stop: once the commas are removed, the spreadsheet reads a clean number.
What was checked before sending
A date whose day is over 12 (02/28/2026) serves as proof of the source format.
The sum of the month’s prices is compared with the total shown by the transaction software.
Three mandates picked at random are checked against their record in the software.
Rough scale: two hours of manual rework every month, and no more mandates dated 11 March instead of 3 November in letters to owners.
Example 2
Amounts as text from a cosmetics manufacturer in Angoulême
Amandine works in sales administration at a 50-employee cosmetics manufacturer in Angoulême. Resellers place orders through a form where the amount excl. VAT is typed by hand: “1 250,50 € HT”, “980”, “2.300,00”. The n8n flow must calculate VAT at 20% and write the amounts excl. VAT and incl. VAT to the orders spreadsheet.
An order, from form to spreadsheet
10 h 02Order entered
“1 250,50 € HT” typed by hand by the reseller.
10 h 02Amount as a number
1250.5, or empty if unreadable.
10 h 02Price incl. VAT calculated
1500.6, rounded to the nearest cent by round(2).
10 h 03Sales administration notified
The amount displayed in French format in Teams.
Request 1
n8n, nœud Edit Fields, champ montant_ht (Number) : l'expression du budget de la leçon, adaptée pour retirer aussi « HT ».
Champ montant_ttc (Number) : {{ ($json.montant_ht * 1.2).round(2) }}
Model answer
“1 250,50 € HT” gives montant_ht 1250.5 and montant_ttc 1500.6; “980” gives 980 and 1176; “2.300,00” gives 2300 and 2760.
Amandine puts the incl. VAT calculation in a second Edit Fields node, after the first, so that montant_ht is already a number. The flow does the calculation, never an AI.
Request 2
Message Teams à l'ADV : Commande de {{ $json.revendeur }}, {{ $json.montant_ttc.toLocaleString('en-GB', { style: 'currency', currency: 'EUR' }) }} TTC.
Model answer
Order from Parfumerie des Halles, €1,500.60 incl. VAT.
The number stays a number in the spreadsheet; only its presentation in the message is put into French format.
What was checked before sending
An order with an amount “à confirmer” sent on purpose: montant_ht empty, montant_ttc not calculated, order flagged to Amandine.
A day’s total incl. VAT compared with the sum recalculated in the spreadsheet.
The VAT rate is written in the sheet: if it changes for a product, the flow is changed in one place only.
Rough scale: around twenty orders a day with no retyping or manual calculation, and no more rounding gaps between the spreadsheet and the invoices.
Example 3
Messy phone numbers from a plumbing and heating engineer in Mérignac
Didier runs a 4-person plumbing and heating business in Mérignac. Call-out requests come in through the website form with phone numbers in every possible shape and the address in a single field (“12 rue des Pins, 33700 Mérignac”). He uses Zapier, Professional plan, to create the appointment in his calendar.
The form, before and after
Before
Phone numbers in every shape
Address in a single field
Call-back errors
After
Phone number standardised, country France
Street and town separated
Incomplete number flagged, never filled in
Request 1
Formatter by Zapier, Numbers, phone number format, country: France.
Input: the form’s Phone field.
Model answer
“06.12.34.56.78” and “+33612345678” come out in the same normalised form; “06 12 34” comes out unchanged.
On the first attempt, the country had been left as the United States and every number came out unchanged. Didier adds a filter: if the phone number comes out with fewer than 10 digits, the appointment is not created and the request is flagged to him.
Request 2
Formatter, Text, splitting (Split) the address on the comma.
Part 1: street; part 2: postcode and town.
Model answer
Street: 12 rue des Pins; Postcode and town: 33700 Mérignac.
An address written without a comma stays in one block: the second part is empty, and Didier reads the original address. He has added two separate fields to the form, street and postcode, for future requests.
What was checked before sending
Ten real, anonymised requests run through the Zap before going live.
An incomplete number sent on purpose: no appointment created, request flagged.
Formatter gives no warning when it fails: the filter that follows is the only alarm.
Rough scale: five minutes per request spent retyping and calling back over a misread number, on around sixty requests a month.
Karine is an accountant at a 20-employee locksmith and metalwork company in Villenave-d’Ornon. She is moving from an old invoicing package to Pennylane and has to transfer the customers and their outstanding balances into a Google Sheets file before import. Here are six lines from the export, copied exactly as they are. For each column, say what gets fixed and what gets flagged, and write the n8n (or Make) expressions that reformat each column. Then fill in the Data box of the sheet.
Spot, column by column, the different formats that coexist.
Classify each problem as green (safe fix), orange (left empty and flagged) or red (never guessed).
Write the expressions for the date, the amount, the phone number and the postcode.
Write the Data box of the sheet and say how you will test it.
See the answers
The support desk and its diagnosis
Client
Last invoice
Outstanding balance
Phone
Postcode
Diagnosis
SARL DUPRAT
2026-10-28
1 250,50 €
05.56.12.34.56
33140
ISO date, amount as text: green
mme lopez
28/09/2026
320
+33 6 98 76 54 32
33 400
Case, +33, space in the postcode: green
Garage Central
10-03-2026
2.480,00
0556
33130
Ambiguous date (10 March or 3 October): orange; incomplete phone number: orange
Mr Petit
to be checked
06 11 22 33 44
1000
Empty date, unreadable balance: orange; postcode missing its zero: green
CAVE DU PORT
15/11/2025
-85,00
05 57 00 00 00
33000
Negative balance (credit note): keep it, not an error
Boulangerie Marty
31/02/2026
410,00
0556778899
33600
Impossible date: orange
The migration expressionsJavaScript
// date : deux formats sûrs (ISO et JJ/MM/AAAA), tout le reste vide
{{ (() => { const t = String($json['Dernière facture'] || '').trim(); let d = DateTime.fromISO(t); if (d.isValid === false) d = DateTime.fromFormat(t, 'dd/MM/yyyy'); return d.isValid ? d.toFormat('dd/MM/yyyy') : null; })() }}
// encours : nombre, signe moins gardé, sinon vide
{{ (() => { const b = String($json['Encours'] || '').replace(/[\s€]/g, '').replace(/\.(?=\d{3}(\D|$))/g, '').replace(',', '.'); return /^-?\d+(\.\d+)?$/.test(b) ? Number(b) : null; })() }}
// code postal : texte à 5 chiffres
{{ String($json['Code postal'] || '').replace(/\s/g, '').padStart(5, '0') }}
The date “10-03-2026” is the central trap: depending on the source software, it can mean 10 March or 3 October. The expression recognises it neither as ISO nor as DD/MM/YYYY and leaves it empty: Karine will check it against the invoice. “31/02/2026” is rejected by Luxon, which knows February does not have 31 days. The wine shop’s negative balance is a credit note: the minus sign is kept.
Data box of the “Migrate customers from the old software” sheet
Box
What is written
Data
Customer, last invoice (DD/MM/YYYY or empty), outstanding balance as a signed number or empty, phone 0X XX XX XX XX or empty, postcode as 5-digit text. Personal data: yes (private customers).
Inspection
Amber: every row with an empty value is reviewed by Karine before import into Pennylane; total outstanding compared with the old software's.
Practise
Three more exercises, from the most guided to the most demanding. The material is provided in full: copy it into your tool, then check your work against the criteria before opening the answers.
Level 1 · guided10 min
Ten values to reformat by hand
Without a tool, write the clean value for each of the ten values, in the required format, or “empty, to flag” if the transformation is not certain.
Dates 1 and 2 change day once converted to Paris time
Values 4 and 6 are left empty and flagged
Postcode 7 becomes 04000
Amount 10 becomes 1200, the full stop being a thousands separator
See the answers
Value
Result
Why
1
16/11/2026
11:30pm UTC = 12:30am in Paris in November: the next day
2
02/07/2026
10:15pm UTC = 12:15am in Paris in July: the next day
3
3400
Space, comma and € removed
4
empty, to flag
“environ” (“approximately”): not a reliable number
5
07 61 22 48 90
+33 replaced by 0
6
empty, to flag
9 digits: the missing 0 can’t be guessed
7
04000
Leading zero lost by a spreadsheet
8
33520
Space removed
9
DE LA FUENTE
Capitals
10
1200
Full stop followed by three digits: thousands separator
Check your answers
Here are ten values, the required format for each and my answers: [paste the material and your answers]. For each value, say whether my answer is right. For the dates, explain the calculation of the time difference with Paris on that exact date.
Roughly what you should get
One comment per value, with the one-hour offset in winter and two-hour offset in summer explained for dates 1 and 2.
Level 2 · independent20 min
A caterer’s orders
A 14-person caterer in Bègles receives its orders by webhook. Write the n8n expressions for the Edit Fields node that produce: the event date in the format “samedi 12 décembre 2026”, the number of covers as a number, the deposit amount (30% of the total incl. VAT, rounded to the cent), and the customer's name in capitals. Say what happens to an order whose total is empty.
The material to work on
JSON REÇU PAR LE WEBHOOK
{
"client": " famille bernard ",
"date_evenement": "2026-12-12",
"couverts": "80",
"total_ttc": "4 320,00",
"formule": "Buffet chaud"
}
Check your work
The date is read as ISO and written in French with setLocale('fr')
Place settings become a number
The deposit is calculated on the total converted to a number, then rounded
An empty total gives an empty deposit, not zero
See the answers
The Edit Fields node fieldsJavaScript
// date_lisible
{{ DateTime.fromISO($json.body.date_evenement).setLocale('fr').toFormat('cccc d LLLL yyyy') }}
// couverts (Number)
{{ Number(String($json.body.couverts || '').trim()) || null }}
// total (Number) : nombre propre ou vide
{{ (() => { const b = String($json.body.total_ttc || '').replace(/[\s€]/g, '').replace(/\.(?=\d{3}(\D|$))/g, '').replace(',', '.'); return /^\d+(\.\d+)?$/.test(b) ? Number(b) : null; })() }}
// acompte (Number), dans un second nœud Edit Fields
{{ $json.total === null ? null : ($json.total * 0.3).round(2) }}
// client
{{ String($json.body.client || '').trim().toUpperCase() }}
Expected results: “samedi 12 décembre 2026”, 80, 4320, 1296, “FAMILLE BERNARD”. Data from an n8n webhook arrives under body, hence $json.body. An empty total gives an empty deposit: writing 0 would suggest no deposit is due.
Level 3 · demanding case35 min
The Code node for the stock migration
A hardware wholesaler in Cenon with 18 employees is migrating its stock from an old file. Write the JavaScript for a Code node (“Run Once for All Items” mode) that reformats the four columns and adds an a_verifier field listing each row's problems. Then say which rows in the material will be marked for checking.
A negative or unreadable quantity is flagged, not corrected
ISO and DD/MM/YYYY dates are accepted, others are flagged
The code returns one item per row with the a_verifier field
Rows 2, 3 and 4 are marked for checking
See the answers
The Code node, “Run Once for All Items” modeJavaScript
// Lit une date ISO ou JJ/MM/AAAA, sinon null
const lireDate = (t) => {
let d = DateTime.fromISO(t);
if (d.isValid === false) d = DateTime.fromFormat(t, 'dd/MM/yyyy');
return d.isValid ? d.toFormat('dd/MM/yyyy') : null;
};
// Nombre propre (virgule ou point décimal), sinon null
const lireNombre = (t) => {
const b = String(t || '').replace(/[\s€]/g, '').replace(',', '.');
return /^-?\d+(\.\d+)?$/.test(b) ? Number(b) : null;
};
return $input.all().map((item) => {
const l = item.json;
const ref = String(l.ref || '').trim().toUpperCase();
const qte = lireNombre(l.qte);
const prix = lireNombre(l.prix);
const maj = lireDate(String(l.maj || '').trim());
const problemes = [];
if (ref === '') problemes.push('référence vide');
if (qte === null || qte < 0) problemes.push('quantité à vérifier');
if (prix === null) problemes.push('prix illisible');
if (maj === null) problemes.push('date à vérifier');
return { json: { ref, qte, prix, maj, a_verifier: problemes.join(', ') } };
});
Line
Result
a_verifier
1
VIS-4X40, 1200, 0.08, 02/10/2026
(vide)
2
CHEV-6, -5, 0.35, 02/10/2026
quantity to check
3
ECROU-M8, empty, 0.12, empty
quantity to check, date to check
4
(empty), 40, 1.2, empty
empty reference, date to check
The Code node is the last resort, when expressions become unreadable. It keeps the same rules: fix what is certain, flag the rest. The date “2026-13-01” is rejected because there is no thirteenth month; the negative quantity is flagged, as it could be a genuine stock-out or a typing error.
All the course prompts to copy, both for the assistant that helps you build and for the AI step of a flow, including answers, practical examples and practice tasks, sorted by module and lesson, with filters to find the right one.
For each lesson, the main exercise and the three graded practice tasks with their materials, to do on paper or alongside your automation platform; all the answers are grouped at the end.
The course’s practical examples, job by job: the situation, the prompt as it was written, the model answer and what was checked before letting the flow run.
All the lessons in a single PDF: objectives, written course with its diagrams, tables and requests, common mistakes, exercise and key takeaways. The practice exercises and answers are in the workbook, the examples in the collection.
Your notes stay on this device; they are not sent anywhere.
A question for the tutor
A result that doesn’t match the model answer, a prompt that gets you nowhere, a case specific to your business: write to us with your prompt and the response you got. A Bonbay Académie trainer replies within 24 working hours, on your case.