Skip to main content

Set a default value

Default values can be set for any column and will be set whenever a new row is added. You can set default values in Column settings.

Video demo


By default, the field’s value is undefined. This value is ignored by Firestore, so the field won’t be set at all in the database.


Setting the default value as null makes it possible to filter rows by empty fields.


Setting a static value will make all new rows have the same value for this field by default.


Setting a dynamic value lets you use JavaScript code to generate a default field value.


When user creates an account user document would be created. the document would need a default currency based on the user's country . if you have countries collection with all the settings available you can do the following:

const defaultValueFn: DefaultValue = ({ row, db }) => {
// set default currency of user's account
const countryDoc = await db.collection("countries").doc(;
const currency = countryDoc.get("currency");
return currency;

Alternatively you can get the information form an external api to set the default value

const defaultValueFn: DefaultValue = ({ row, db }) => {
// set default currency of user's account
const resp = await fetch(
const respData = await resp.json();
// get the currency code from the response
const currencyCode = Object.keys(respData[0].currencies)[0];
const currency = respData[0].currencies[currencyCode];
return {
code: currencyCode,
symbol: currency.symbol,


Your code has access to the following parameters and can use the await keyword.

You can also use npm packages using CommonJS require imports.

rowRecord<string, any>All data in the current row.
refDocumentReferenceReference to the corresponding Firestore document of the current row.
dbFirestoreAccess to the full Cloud Firestore instance to access any collection or document.
authAuthAccess to Firebase Auth via Admin SDK
storageStorageAccess to Firebase Storage via Admin SDK
rowyRowyAccess to cloud function metadata secret Manager and storage utilities


Example: Parent document

Use the row ref to get a value from the parent document.

const defaultValueFn: DefaultValue = async ({ ref }) => {
const parentDoc = await ref.parent.parent.get();
return parentDoc.get("FIELD_KEY_HERE");

Example: Any document

Use db to get any document in your database.

const defaultValueFn: DefaultValue = async ({ row, db }) => {
const query = await db
.where("aField", "==", row.someKey)

Example: npm package

Use an npm package to generate a UUID.

const defaultValueFn: DefaultValue = ({ row, db }) => {
const { v4: uuidv4 } = require("uuid");
return uuidv4();

Example: reference Data

Store document id in the document, for easy queries

const defaultValueFn: DefaultValue = ({ ref }) => {