Code in Inputs
Available in version 1.1.72 (not yet live).
Use ${...}
for an expression and $${...}
for a code block. Expressions insert their result. Code blocks run full code and must return
a value to insert. All code runs locally on your device.
Using ${...}
(expression)
${...}
(expression)Examples
"This is my secret password stored locally: ${
await zw.deviceStorage.get("password")
}""This is my random number: ${
Math.random()
}""This is my formatted input ${
"{id: 1234, name: Country Code}".trim().toUpperCase()
} Note: table/variable references like{id: 1234, name: Country Code}
are not code; they’re replaced with their values. If you need that value as a string inside code, wrap it in quotes (as above) or read it withzw.getRef
: ${(await zw.getRef({ ref_id: 1234, name: "Country Code" })).trim().toUpperCase()
}".
Using $${...}
(code block)
$${...}
(code block)Examples:
"This is a value returned from an API: $${
import axios from "axios"; // any import auto-installs locally const res = await axios.get("https://mydomain.com/my/api/url"); return res.data;
}."
"This is my input with more complex formatting: $${
const fullAddress = await zw.getRef(ref_id: 1234, name: "Address" }); const splitValues = fullAddress.split("country code: "); const countryCode = splitValues[1]; if (!countryCode) { await zw.log({ message: "no country code", status: "warning" }); return "unknown"; } return countryCode.toUpperCase().trim();
}."

Last updated
Was this helpful?