sfShowFormStatusPopup
Renders the standard form status selection popup and executes a callback function when user has selected a status.
Syntax
sfShowFormStatusPopup(filters, callback)
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
filters | json | no | JSON array of conditions and filters to be applied on the form statuses to make them visible in the popup. See filters. |
callback | function | yes | Code block to be executed after the form status popup is shown and the user has clicked ON after selecting a form status from the list. The callback function contains one parameter:
See callback function. |
filters
A filter is a set of criteria to limit the form statuses (from all form statuses linked to the form) to be listed in the form status popup.
It is a JSON array of conditions and filter expressions. The general format is:
[
{
"Condition": "<Expression>",
"Filter": "<Expression>"
}
...
]
Both Filter and Condition are standard expressions.
Expressions are case sensitive. Form fields, context variables and constants used in an expression must be in the expected case.
Filter attributes
These attributes are available to be used in a Filter expression.
Attribute name | Description |
---|---|
FormStatus | Unique name of the form status |
SystemStatus | Related system status (OPEN, COMP or REJ) |
Operators supported
Symbol | Name | Supported in Condition expression | Supported in Filter expression |
---|---|---|---|
== | equals to | Yes | Yes |
!= | not equals | Yes | Yes |
> | greater than | Yes |
|
>= | greater than or equals to | Yes |
|
< | less than | Yes |
|
>= | less than or equals to | Yes |
|
Order of evaluation
If there are multiple conditions, they are evaluated from the first to the last in a serial order. If a condition is satisfied, the filter expression is evaluated on the list of form statuses linked to the form (that the current user has permission to). The form statuses that match the filter expressions are displayed in the form status popup. Any remaining condition-filter pair after the first condition that is satisfied are ignored.
If there is only one form status that qualifies the filter expression, the form status popup is not shown. The form status is auto selected and the callback function is called.
If there is no form status that qualifies the filter expression, an error message is shown to the user and the callback is discarded.
Usage examples
Example 1
Let us consider a form contains a button SkipAndContinue that allows an operator to save the form without requiring them to complete the rest of the form. When the user clicks on the button, the standard form status popup should open. If the user chooses to complete the form, a field AdditionalNote should have the text “Material classification skipped.”
sfShowFormStatusPopup('', function(systemStatus) {
if(systemStatus == 'COMP') {
sfSetValue('control_additionalnote','Material classification skipped.');
// Continue saving the form
}
})
Example 2
Let us consider an inspection form that can have these statuses (mentioned along with their system statuses) in its workflow:
Open (OPEN)
PendingSurveyorApproval (OPEN)
ApprovedBySurveyor (OPEN)
PendingSupervisorApproval (OPEN)
ApprovedBySupervisor (COMP)
In the simplest workflow, an inspection may be done by an inspector and approved by the supervisor.
Open > PendingSupervisorApproval > ApprovedBySupervisor
But there may be inspections where an execution plan is required. In this case, an additional intermediate would be required to get an approval from the surveyor.
Open > PendingSurveyorApproval > ApprovedBySurveyor > PendingSupervisorApproval > ApprovedBySupervisor)
In case of such inspections, a checkbox in the form RequiresExecutionPlan is checked. The form statuses PendingSurveyorApproval and ApprovedBySurveyor should be visible only if RequiresExecutionPlan is checked.
var statusFilters = [
{
"Filter": "FormStatus != 'PendingSurveyorApproval' && FormStatus != 'ApprovedBySurveyor'",
"Condition": "{RequiresExecutionPlan} == '' || {RequiresExecutionPlan} == '0'"
}
];
sfShowFormStatusPopup(statusFilters, function(systemStatus) {
// Continue saving the form
})