board logo
WUICTeam
  • WUICTeam
  • 100% (Exalted)
  • Newbie Topic Starter
11 days ago
Question
In an action callback I call wtoolbox.navigateToNextStep(record, null, esito) and want to run a fallback when the workflow does not navigate. I wrote if (!wtoolbox.navigateToNextStep(...)), but when a condition guard fails the fallback never runs and the user just sees a warning. What is going on, and how should the check be written?

Answer
The method has three outcomes, not two: true, false and the string 'blocked'. Because 'blocked' is a non-empty string it is truthy, so !result is false when a guard stops the navigation. That is intentional: the fallback would otherwise let the callback bypass a block that the graph imposed.

  • true: a target step was resolved and the navigation started.
  • false: there is no active workflow link for this action (no workflow context, or no outgoing links in the graph). Here a fallback makes sense.
  • 'blocked': links exist, but no branch can be taken because guards or permissions are not satisfied. The user already sees a warning with the failed expression and nothing is navigated.


So compare explicitly against false:


const esito = await wtoolbox.dataService.update(entity, row, datasource);
const nav = wtoolbox.navigateToNextStep(record, null, esito);
if (nav === false) {
  // no workflow link for this action: do the hardcoded behavior
  wtoolbox.enqueueNotification({ message: 'No next step configured' });
}
// nav === 'blocked': the warning was already shown, do nothing else
resolve(esito);

The third argument is the payload exposed to Condition and Switch expressions (for example payload.stato === 'approvato'). Expressions that mention payload are not evaluated at the pre-click gate, because the payload does not exist yet: they are applied when the branch is chosen inside navigateToNextStep. Common mistake: testing the result with !nav or nav == true instead of the strict comparisons above.

Documentation: Workflow Designer