Logic Actions

The solitary action in this group supports conditional branches, separate branches of actions within a single action script, based on a formula (“If this is true, then do this; if not, do that”). All this is performed within the Action Framework, without using JavaScript snippets with If/Else statements.

Run action sequence

Used to select a reusable action sequence to run within the current set of actions.

  • Action sequence: The action sequence to run.
  • Description: The description entered within the chosen action sequence’s properties.

Note

In addition to the Action Sequence property, any inputs that have been specified on the reusable action sequence are displayed as properties. For more information, see Inputs.

Warning

Use action sequences thoughtfully. If there are actions within an action sequence that are contingent on context, recognize that the context changes depending upon where and how the sequence is invoked.

When invoking an action sequence, be sure to examine the individual actions for properties and merge syntax that rely on context, and ensure that you are using the correct model conditions for that action to work within the context requirements.

Run a JavaScript snippet

Like Skuid Javascript snippets? Use a snippet alongside other actions without adding more code to the existing snippet.

  • Name of snippet to run: The exact name of the snippet.

Snippets must be registered using skuid.snippet.registerSnippet(snippetName, snippetFunction).

Publish event

Use the Action Framework to publish events. Subscribe to these events using an event-triggered action sequence or with the skuid.events.subscribe() API.

  • Event name: The name of the event to be published.

  • Publishing scope: Determines how “far” outside the current page that the published event will reach.

    • All active pages and Lightning Components: The event will be published on all Skuid pages and all Lightning components active on the current Lightning page.
    • All active pages: The event will be published on all Skuid pages that are active in the current window.
    • Only this page (default): The event will only be published on the current Skuid page.
  • Channel (optional): Determines on which “channel” an event is published, providing another option to narrow the scope of an event. An event subscription only activates if it is also pointed to the channel specified here, even if the event name is the same.

Working with event parameters

It’s possible to add parameters, additional pieces of data, when publishing an event. Parameters enable events to be a more robust information-passing mechanism as opposed to a basic alert that something has occurred.

To add parameters:

  1. Click the dots-vertical More Options icon on the Publish event action.
  2. Click Add parameter.
  3. Enter the parameter’s information:
    • Parameter name: The name of the parameter. Ensure this name is memorable and recognizable; it must be used anytime you wish to retrieve a parameter’s value.
    • Value: The value of the parameter, which can be any hard-coded string, merge variable, or combination of the two.

Event parameters are automatically passed into event-triggered action sequences as inputs, accessible through the $Input merge variable.

Note

You must know the parameter’s name to retrieve its value through the $Input merge variable. It’s not possible to declaratively retrieve all parameters without specifying them.

Event parameter example

Consider this runtime example:

This experience is created with a Show toast message action, an event, and an event parameter.

First, create the button and action:

  1. Drag a Button Set into the canvas.
  2. Set the Button label to Publish “exampleEvent”.
  3. Navigate to the Actions tab.
  4. Add a Publish event action and set its properties:
    • Event name: exampleEvent
    • Publishing scope: Only this page
  5. Click dots-vertical More options > Add parameter.
  6. Set the parameter’s properties:
    • Parameter name: exampleParameter
    • Value: Some example data

It’s now possible to access this parameter declaratively in an action sequence with {{$Input.exampleParameter}}.

  1. Create an event-triggered action sequence.

  2. Set its properties:

    • Sequence name: Listen for events and show toast
    • Event name: exampleEvent
    • Listen for events: Only this page
    • Event channel: Leave this blank
    ../../../_images/publish-event-example-action-sequence.png
  3. Create a new action in the sequence and set its properties:

    • Action type: Show toast message
    • Message to display: {{$Input.exampleParameter}}
    • Display duration: 4 seconds
    • Click to dismiss: Leave this unchecked
    • Style variant: Default
    • Position: Bottom left
    ../../../_images/publish-event-example-action.png

Save and preview the page. Anytime the button is pressed, a toast message appears containing the event’s parameter value.

Branch

This action supports conditional branches, separate branches of actions within a single action script, based on a formula (“If this is true, then do this; if not, do that”). All this is performed within the Action Framework, without using JavaScript snippets with If/Else statements.

  • Formula context model (optional): Establish context for the formula by selecting the model being referred to with merge syntax.

  • Branch Formula: In this field, use merge syntax as well as Skuid’s formula functions to dictate the logic of the branch. Some examples:

    • For toggleable fields that result in a boolean value:

      • {{FieldName}} == true
    • To compare fields to values, encase the values in quotation marks:

      • {{ABC}} == "123"
  • Description: Useful for Skuid administrators, the text entered in this field displays beside the word “Branch” in the Actions list.

  • After running the branch: Determines what happens after this branch action is complete. This property only applies to the branch if the formula evaluates as true.

    • Do not run any additional actions: Do not run any additional actions from the actions list after this branch completes.
    • Continue with next action: Move on to the next action (or branch) in the actions list after this branch completes.

    Note

    If nesting branches within branches, then be aware that the property of Do not run any additional actions on a branch within a branch will stop all additional actions, even if the top-level branch was set to continue.

Using branch actions

  1. Create a new action and select Branch as the action, then edit the branch properties.

  2. Add actions to the branch:

    • To add true actions to the branch, click add Add If-True Action on the branch and format the action. With conditional branching, the actions Skuid performs depend on if the branch’s logic is true:

      • If the formula is true, then the If-True actions connected to this branch occur.

        • If the branch is set to Do not run any additional actions, then Skuid ignores any actions listed after the branch action.
        • If the branch is set to Continue with the next action, then Skuid proceeds with any actions listed after the branch.
      • If the formula is false, Skuid skips the branch—and all actions listed within it—and proceeds with any actions listed after the branch.

    • To add actions that occur if the branch’s logic is not true, click add Add action (at the top level) and place those actions after the branch action.