Lets quickly see, how to use a switch case in action chain
Consider that we are going to have a menu with items saying "Create Note", "Export Notes","More Settings". When each menu item is clicked or chosen, we need to do certain action / action chain. For this, first let's create a page and drag and drop the "Menu Button". When you drop it in the title secion you will get options to choose where you want to place the menu "startControl","endControl","Default". Let's choose it as end control to place it at the end of the title bar.
Once you add it, it will create an action chain. In which you can see an Input Parameter available in the action chain which has the menu id.
Like this, add action to each case. That's all. Now when you click on a menu item corresponding action will be executed. There is another way also to get this done. Instead of switch, we can use "If" logic. But if you have many cases then "If" will make your action chain more clumsy. When you have more cases, go for "Switch". when you have 1 or 2 cases then go for "If"
Consider that we are going to have a menu with items saying "Create Note", "Export Notes","More Settings". When each menu item is clicked or chosen, we need to do certain action / action chain. For this, first let's create a page and drag and drop the "Menu Button". When you drop it in the title secion you will get options to choose where you want to place the menu "startControl","endControl","Default". Let's choose it as end control to place it at the end of the title bar.
In the page structure choose the "Menu" and go the "Data" tab. Add and Edit the menu items (oj-option). here we have the menu item id's ad "newNote","export","settings"
When the menu is selected we need to do some action. For that we need to map an action to the menu. In the page structure choose the "Menu" and go the "Events" tab. Add 'ojAction' Event.
Once you add it, it will create an action chain. In which you can see an Input Parameter available in the action chain which has the menu id.
this menuId variable will contain the selected menu id. we can use this in the switch case to process each menu item. Drag and Drop the switch action. Here in the value field we are going to pass the menuId variable
value will be {{ $chain.variables.menuId }}
Now for each case we can further add navigation or any other action. In this example let's add "Navigate" action. When you drop any action on the (+) under (Add Case). It will ask for outcome name. Here we need to give the menu id's that we configured while adding menu itemsLike this, add action to each case. That's all. Now when you click on a menu item corresponding action will be executed. There is another way also to get this done. Instead of switch, we can use "If" logic. But if you have many cases then "If" will make your action chain more clumsy. When you have more cases, go for "Switch". when you have 1 or 2 cases then go for "If"
Comments
Post a Comment