Calling another Action
Action Logic Editor allows calling one Action from another Action's logic. This may be helpful in multiple situations
1. You have a reusable block of logic that is relevant in multiple places. As an example, consider the Action, Navigate to Header Link which may be relevant in multiple other Actions.
Consider the actions, Verify Account Summary and Verify Recent Orders. In both these actions, as a first step, it is necessary to navigate to the appropriate header link by hovering on a top navigation link and selecting a doormat menu. The logic to select a given header link can be put as part of a central action, which can be called from both.
Action 1: Verify Account Summary
Navigate to Header Link ('My Account')
<logic to verify account summary>
Action 2: Verify Recent Orders
Navigate to Header Link ('My Orders')
<logic to verify recent orders>
2. You may want to break down a single action into multiple parts for the sake of clarity and readability.
Consider the action, Populate Payment Page which fills information on payment type, shipping preference and shipping address. Even thought it is possible to write entire logic in a single action, it helps greatly with readability and maintainability, by breaking down into multiple sub-actions.
Action: Populate Payment Page
Populate Payment Type
Select Shipping Preference
Enter Shipping Address
How to call an Action
To call an action in the logic, type "/action" and then select the Action to call. If the called action requires any input parameters, you will be prompted to provide values. You can also capture output from the called action into a local or action output parameter.
Which actions can be called?
In order to maintain a proper separation of concerns and adhere to the core principles of modularity and reusability, accelQ places certain restrictions on which actions can be called from a given action. Not every action can be called from another action. Here are the rules of eligibility. From a given action, you can call another action only when it satisfies all of the following conditions.
- Destination Context of the called Action should either match with the Destination Context of the Action where it is called or should be “Current Context”
- Called Action should be available in the Context of the Action where it is being called. Either the called Action should belong to the same Context as the Action where it is being called or should have been shared with the Context of such Action.
- Should not create “recursive” situation where Actions call each other cyclically (System will automatically check for this condition)
- An Action cannot call itself
Call-Action and Action-Sharing
Action sharing compliments action calling capabilities very closely. As noted, you can call an action only when it belongs to the same context where the calling action belongs. This may not always be possible based on how you setup and separate your contexts. In such cases, you can simply share an action defined in another context with the context where you want to call it.
In the example in the first section, Navigate to Header Link is an action that is useful in multiple actions belonging to multiple contexts. When you share this action with all relevant contexts, it readily becomes available to be called.