Form Runner functions
Availability
[SINCE Orbeon Forms 2016.2]
These functions are only available within the context of Form Runner.
Configuration
These functions are automatically available from Form Runner.
For plain XForms, the user needs to import the Form Runner function library by adding the following attribute on the first <xf:model>
:
Namespace
These functions are in the Form Runner namespace:
This namespace is usually bound to the fr:
prefix:
Base functions
fr:app-name()
Return the form's application name.
fr:control-string-value()
[SINCE Orbeon Forms 2018.1]
$control-name
must correspond to an existing value control (statically)
$follow-indexes
if missing, takes the value
false()
.if
false()
This finds the "closest" matching control without checking repeat indexes. When descending into repeat iterations, all repeat iterations are chosen.
if
true()
This finds the "closest" matching control by following repeat indexes when possible. When descending into repeat iterations, the iteration matching the enclosing repeat's current index is chosen.
This function returns the value or values of a Form Runner control by name as a sequence of strings, or an empty sequence if the control or value is not found.
[SINCE Orbeon Forms 2021.1.3]
$section-name
specifies the name of a form section identifying one or more (in case of repeated sections) section template instances included in the form
the search is limited to searching within those sections
if the section name does not identify a section containing a section template, the function returns the empty sequence
fr:control-typed-value()
[SINCE Orbeon Forms 2018.1]
Like fr:control-string-value()
(see above), but it returns:
an XPath
array()
of all the values foundeach value has an XPath type when possible, including:
xs:string
xs:boolean
xs:integer
xs:decimal
xs:date
xs:time
xs:dateTime
$follow-indexes
if missing, takes the value
false()
.if
false()
This finds the "closest" matching control without checking repeat indexes. When descending into repeat iterations, all repeat iterations are chosen.
if
true()
This finds the "closest" matching control by following repeat indexes when possible. When descending into repeat iterations, the iteration matching the enclosing repeat's current index is chosen.
For indexes in the array where it is not possible to return a typed value, the empty sequence is returned instead.
NOTE: The reason this returns an XPath array and not an XPath sequence is that this lets the caller know which values are the empty sequence. This wouldn't be possible with an XPath sequence.
[SINCE Orbeon Forms 2021.1.3]
$section-name
specifies the name of a form section identifying one or more (in case of repeated sections) section template instances included in the form
the search is limited to searching within those sections
if the section name does not identify a section containing a section template, the function returns the empty sequence
fr:created-dateTime()
[SINCE Orbeon Forms 2016.3]
Return the creation date of the current form data as of the last read from the database if available, and the empty sequence otherwise (such as in "new" mode).
fr:workflow-stage-value()
[SINCE Orbeon Forms 2020.1]
If a workflow stage has been set for the current form data, then the function returns that workflow stage, as a string. And if no workflow stage has been set, the function returns an empty sequence. Also see the set-workflow-stage
action.
The function name has a value
suffix as we anticipate future versions of Orbeon Forms to associate to the workflow stage a label, and also possibly a description, for cases when the workflow stage needs to be made visible to users. Thus the value will be only used to keep track of the current workflow stage, while the label and description will be user facing, and if needed localized.
fr:dataset()
[SINCE Orbeon Forms 2017.1]
Return the root element of the XML document containing the given dataset.
If the dataset does not exist, return the empty sequence.
For more on datasets, see Datasets.
fr:document-id()
Return the form's document id.
fr:form-name()
Return the form's form name.
fr:form-title()
[SINCE Orbeon Forms 2018.1]
Return the form's title for the current form language.
fr:form-runner-link
[SINCE Orbeon Forms 2022.1]
$link-type
one of:
'edit'
,'view'
,'new'
,'summary'
,'home'
,'pdf'
Create a link back to Form Runner for the given page type. If applicable, the current form's application name, form name, form version, and document id are used.
Example:
might return:
The first part of the URL can be configured with the oxf.fr.external-base-url
property.
fr:form-version()
Return the form definition's current version. By default, when versioning is not enabled, or in test
mode, return 1
.
fr:is-background()
[SINCE Orbeon Forms 2021.1]
Returns whether the form is running in the background.
See also Run form in the background API.
fr:is-browser-environment()
[SINCE Orbeon Forms 2021.1]
Returns whether the form runtime is running entirely in a browser environment.
As of Orbeon Forms 2021.1, this returns:
true()
: when the form runs in offline mode (for example using the "Test Offline" Form Builder button)false()
: in all other cases
fr:is-design-time()
Return whether the form is shown at design time within Form Builder.
This function is particularly useful for XBL components.
fr:is-embedded()
[SINCE Orbeon Forms 2021.1]
Returns whether the form is running in embedded mode. This includes embedding with:
the Offline mode [EXPERIMENTAL SINCE Orbeon Forms 2021.1]
This can, for example, be used to show and hide buttons or form sections only when the form is embedded.
[SINCE Orbeon Forms 2021.1.4 and 2022.1]
The function supports an optional parameter:
Possible values:
portlet
: if passed, returns true if embedding is done via the Form Runner proxy portletjava-api
: if passed, returns true if embedding is done via the Form Runner proxy portlet
Example:
fr:is-form-data-saved()
Return whether the form data has been saved (including after the set-data-status
action was called with a status
parameter set to safe
).
fr:is-form-data-valid()
Return whether the form data is valid, that is the form data does not contain any errors.
fr:is-noscript()
Return whether the form is in noscript mode.
NOTE: Starting with Orbeon Forms 2018.1, this always returns false
.
fr:is-pe()
[SINCE Orbeon Forms 2018.2]
Return whether the current version Orbeon Forms is the Professional Edition (PE).
fr:is-readonly-mode()
Return whether the current page is in a readonly mode such as view
, pdf
, or email
.
fr:lang()
Return the form's current language.
fr:mode()
Return the Form Runner mode.
fr:is-draft()
[SINCE Orbeon Forms 2020.1.6]
Returns true
if the user is currently editing a draft, false
otherwise.
fr:modified-dateTime()
[SINCE Orbeon Forms 2016.3]
Return the modification date of the current form data as of the last read from the database if available, and the empty sequence otherwise (such as in "new" mode).
fr:pdf-templates()
[SINCE Orbeon Forms 2018.1]
Return the list of section templates associate with the current form definition. The return value is a sequence of map(xs:string, xs:string?)
, where keys map to values as follows:
path
: the path to the PDF template in the persistence layername
: the name of the PDF template, or the empty sequence if none was providedlang
: the language of the PDF template, or the empty sequence if none was provided
This example shows a dropdown menu which lists the templates with a name:
See also PDF templates.
fr:run-process()
Run the given process given a scope and process content.
This function returns true()
if the process succeeded, and false()
otherwise.
Example:
The function returns an empty sequence if the process contains at least one asynchronous action, and therefore the process result is yet unknown.
fr:run-process-by-name()
Run the given process given a scope and process name.
This function returns true()
if the process succeeded, and false()
otherwise.
Example:
The function returns an empty sequence if the process contains at least one asynchronous action, and therefore the process result is yet unknown.
fr:component-param-value()
[SINCE Orbeon Forms 2018.1]
This function is similar to xxf:component-param-value()
, but is designed to be used in XBL components that are expected to run in the context of Form Runner. It searches parameters in this order:
1
string value of the attribute of the current XBL component's bound node with a name matching the parameter
attribute present
2
current form's metadata instance (see below)
element present
[SINCE Orbeon Forms 2018.2]
3
value of a property, taking into account the current app/form name. For instance, xxf:component-param-value('theme')
called from the fr:recaptcha
component uses the value of the oxf.xforms.xbl.fr.recaptcha.theme.*.*
, following wildcard rules
property defined
4
value of a property without taking into account the current app/form name. For example oxf.xforms.xbl.fr.recaptcha.theme
property, as done by xxf:component-param-value()
property defined
This allows authors of XBL components to:
replace an existing call to
xxf:component-param-value()
byfr:component-param-value()
while maintaining backward compatibility.enable users of the component to have different values for the property by app/form, should they need to.
still allow the component to be used outside of Form Runner.
The Form Runner metadata instance looks like this:
NOTE: The Form Runner metadata instance is maintained by Form Builder. We do not recommend making changes to that instance.
[SINCE Orbeon Forms 2018.2]
The resulting value is always evaluated as an AVT.
[SINCE Orbeon Forms 2022.1.1]
The function can take an optional second parameter, which is the id of a component control in scope.
Wizard functions
fr:is-wizard-body-shown()
[SINCE Orbeon Forms 2016.2]
Whether the wizard's body is visible.
fr:is-wizard-first-page()
[SINCE Orbeon Forms 2016.3]
Whether the currently-shown wizard page is the first relevant page.
fr:is-wizard-last-page()
[SINCE Orbeon Forms 2016.3]
Whether the currently-shown wizard page is the last relevant page. For instance, when using the wizard view, you can use this function to disable buttons until users have reached the last page of the wizard; the following property does so for the "Send" button:
fr:is-wizard-separate-toc()
[SINCE Orbeon Forms 2022.1]
Whether the wizard is configured to have a separate table of contents.
fr:is-wizard-toc-shown()
[SINCE Orbeon Forms 2016.2]
Whether the wizard's table of content is visible.
fr:wizard-current-page-name()
[SINCE Orbeon Forms 2019.1]
If a wizard page is being shown, the function returns the name of the current wizard page name, which is the section name used in Form Builder.
Otherwise, it returns the empty sequence. So an empty sequence is returned if the form is not using the wizard view. This can be used as follows to show a button, say the Submit button, only the last page of the wizard if the form is using the wizard view, but to always show that Submit button if the form isn't using the wizard view.
Authentication functions
fr:can-create()
Whether the current user has the create
permission for the current app/form name (detail page only).
fr:can-delete()
Whether the current user has the delete
permission for the current form data (detail page only).
fr:can-read()
Whether the current user has the read
permission for the current app/form name (detail page only).
fr:can-update()
Whether the current user has the update
permission for the current form data (detail page only).
fr:user-ancestor-organizations()
[SINCE Orbeon Forms 2016.3]
Seexxf:user-ancestor-organizations()
.
fr:user-group()
Seexxf:user-group()
.
fr:user-organizations()
[SINCE Orbeon Forms 2016.3]
fr:user-roles()
Seexxf:user-roles()
.
fr:username()
Seexxf:username()
.
See also
Blog post: A stable function library for Form Runner
Last updated