Record.HasFields
Returns true if a record contains all of the fields you name.
Record.HasFields(record, fields)Returns: A logical value, true or false.
What it does
Record.HasFields tests whether a record has the fields you need. Use it before reading a field that might not be there, for example when two exports have slightly different layouts. It returns true only if every named field is present.
Syntax and arguments
record: the record to test.fields: the field name, or a list of field names, to look for.
Example
A function reads a bank row. Some exports include a Currency field and some do not. The function uses the currency only when it is present.
let
Row = [Date = #date(2026, 3, 31), Amount = 1250],
HasCurrency = Record.HasFields(Row, "Currency"),
Currency = if HasCurrency then Row[Currency] else "USD"
in
Currency
HasCurrency is false for this row, so the default "USD" is used. The query does not fail on the missing field.
Example: a second, different use
Checking that a row carries all the fields a journal import needs: Record.HasFields(Row, {"Date", "Account", "Amount"}) returns true only if all three are present.
Things to watch
- A list of names must all be present, so one missing field gives false.
- It checks the names only, not the values. A field can exist and still be null.
- Use it to fail clearly when a required column is absent, rather than letting an error appear in a later step.
- For a table, compare Table.ColumnNames with the list you expect.
In business terms
Layout checks on monthly and system exports help catch a changed file before the numbers go wrong. A check that stops the refresh with a clear message is better than a total that is silently short.