How to fetch information on demand using an action mashlet

Context

Sometimes, in Decision Insight, you might have some information that does not need to be updated automatically all the time. For this type of information, you can configure an action mashlet so that some information is retrieved on demand only. In a dashboard pagelet, the action mashlet is a button you can click at will whenever you want the data on the pagelet to be refreshed.

Note: This mashlet has been designed to fetch information on a specified instance.

For example, you have a Batch entity used to retrieve additional data from a remote system. Configure an action mashlet to retrieve that remote data on demand. 

Action mashlet configuration

To add an action mashlet to a dashboard, follow these steps.

Step Action
1 Navigate to a dashboard where you want to add an action mashlet.
2

Put the dashboard in Edit mode.

3 Click the Edit icon for a pagelet.
4 In the values area, click the Add value button. The Edit value pop up is displayed.
5

Select the Action mashlet.

6 Click the Select attribute link and Select the attribute you need. Based on our example, click the Select hyperlink for the instance attribute the Batch entity.
7 To format the appearance of your action mashlet button, on the left menu, click Format. You can define the Label, that is the text under the button, and the Action, that is the text on the button itself.
8 To trigger the correct action when you click your button on the dashboard, the button requires an alias. To configure an alias, on the left menu, click Actions.
9

In the action alias field, enter, for example, fetch_batch.

Click the copy icon to the right of the field so you can reuse that alias when specifying a route for the remote data.


Route configuration

Define a route based on the alias for the action mashlet, that is using  <from uri="action:fetch_batch"/> :

<routes xmlns="http://camel.apache.org/schema/spring" xmlns:u="http://www.systar.com/aluminium/camel-util">
   <route>
    <from uri="tnd-action:fetch_batch"/>
        <!-- Use action properties to fetch informations -->
        <setHeader headerName="actionLabel">
            <simple>Action '${body[action]}' on '${body[instance]}' from '${body[dashboard]}' by '${body[user]}' at VT '${body[validTime]}' TT '${body[transactionTime]}' </simple>
        </setHeader>

        <doTry>
           ...
           <!-- Set the body at the end to some string. It will be displayed in the UI -->
           <setBody><simple>${header.actionLabel} Done!</simple></setBody>
           <doCatch>
              <exception>java.lang.Exception</exception>
              <throwException exceptionType="java.lang.RuntimeException" message="Unable to fetch data from webservice because..." />
           </doCatch>
        </doTry>
    </route>
</routes>

When the action is invoked, the route body is set with the following property map:

Property Description
action The action alias
instance The UUID of the instance input selected in the mashlet
validTime The instance creation valid time
transactionTime The instance creation transaction time
dashboard The dashboard name where the action is invoked from
user The user name that invoked the action

Notes:

  • Only one route per action alias can be started at a time
  • If the route throws an error and there is no try/catch, the action is reported as failed with a generic message, the message of the exception in the route above.
  • If the deployment is stopped, all cached statuses are lost.
  • The dashboard is not refreshed automatically when an action is completed. It is refreshed based on its own rhythm or you can refresh it manually.

Related Links