Skip to content
SurogateDocs

Named values

A named value is a value worked out by the portal and read by name, as values.<name>, in any action list or logic flow. A VAT rate, a greeting, a price list from a flow: each is written once and kept for a while.

A value lives in values/<name>.yaml. The file’s name is the value’s name: letters, digits and _, starting with a lower-case letter.

yaml
name:
ro: Cota TVA
en: VAT rate
cache: install
ttl: 3600
value: "1.19"

A value is one of:

  • value: an expression;
  • flow: a flow’s outputs, with flow: { id, inputs }. Read one output as values.<name>.<output>.
  • http: what a service answers, with http: { connector, path, query }.
    • It is a GET through a web connector.
    • The value is the answer’s body.
    • An answer that is not 2xx fails it.
    • A value kept for the whole portal or a site cannot use a connector that each person connects themselves.
  • collection: the published entries of a content collection, with collection: <id>.
    • Each entry is id, slug and values.
    • It is read before the list runs, and is as fresh as the value’s ttl.
    • Only a public collection that visitors may read can be a value, since a value may reach anyone. Each entry’s values are shown in the run’s language.

A value never reaches the portal’s files: a value kept for others must not hold what only some people may read.

cache says for whom a value is kept, and ttl how many seconds (1 to 86,400; 300 when left out):

cacheKept forIts expression may read
installThe whole portallocale, now, other install values
siteEach siteas above, and site and site values
userEach signed-in personas above, and user and user values
noneNobody: worked out every timeeverything above

A value is kept per language too. A value kept for a site or the whole portal never sees the person, even inside a flow it calls: what it keeps is the same for everyone. A value cannot read a value kept for fewer people than it is, and values cannot read each other in a circle. The portal refuses either when the file is saved. A user value is never kept for visitors.

Kept values start afresh whenever the portal’s files change.

Every value a list can reach is worked out before the list runs, each after the values it reads. A value that fails is left out, and the run’s log says why. Reading it is then the action’s error, which its onError can catch.

Values are read as values.<name>. Any other way, such as values["name"], is refused when the file is saved.