Using Data Actions Technical Object

Besides the Data Action Trigger widget you can also use the technical object Data Actions and the related script APIs to run short running data actions via scripts as well as set and read parameter values.

Data actions are a flexible planning tool for making structured changes to model data, including copying data from one model to another. In analytics designer there are two ways of adding data actions to your application:
  • Using the data action trigger widget and related APIs

  • Using the data actions technical objects and related APIs
With the data actions technical object in analytics designer and the related script APIs you can do the following:
  • set the value for a data action paramenter

  • read the value of the data action parameter

  • execute the data action

Prerequisites

Before you can use the technical object Data Actions, there have to be data actions created already.

Please consider as well the following permissions and roles:
  • To create or edit a Data Actions technical object, you need the permission to edit the analytic application.

  • To select a data action in the Data Action Configuration side panel you need the respective read permission for data actions.
  • To execute a data action, you need the respective execute permissions for the selected data action.

Adding a Data Actions Technical Component to the Application

You need to add a data action technical object to the application to be able to use the related script APIs.

  1. In the Scripting section of the Outline, select right next to Data Actions to add a data action.

    The side panel Data Action Configuration opens with an empty description field where you can type in a meaninful description for the data action.

  2. In the Data Action dropdown select one of the data actions that have been created already. The related data action parameters are displayed below.

  3. Enter the values for the parameters either using the member selection or by chosing the given default value that has been set in the data action designer.
    Note
    • To execute a data action successfully, all parameters have to be filled with values. Either in the side panel Data Action Configuration or via the API setParameterValue.

    • The design of the data action itself can't be changed in the Data Action Configuration, only the parameter values can be set here to adjust the data action.

  4. Click Done when you have finished setting the parameters.

For more information about data action parameters, see Add Parameters to Your Data Actions and Multi Actions.

Related APIs
After adding the technical object, as an application designer you can leverage the following APIs to work with data actions in your application::
  • executing data actions

    function execute(): DataActionExecutionResponse;;

  • getting parameter values

    function getParameterValue(parameterId: string): DataActionParameterValue;

  • setting parameter values

    In the following example, a set of dimension member filters is assigned to a parameter of a data action. The code collects the relevant single value and multiple value dimension member filters into an array before the assignment operation. Exclusive filters are ignored, they aren’t supported by the data action.

    Sample Code
    var filters = table.getDataSource().getDimensionFilters(dimensionId);
    var filteredMemberIds = ArrayUtils.create(Type.string);
    
    for(var i = 0; i < filters.length; i++) {
                    if (filters[i].type === FilterValueType.Single) {
                                   var singleFilter = cast(Type.SingleFilterValue, filters[i]);
                                   if (!singleFilter.exclude) {
                                                   filteredMemberIds.push(singleFilter.value);
                                   }
                    } else if (filters[i].type === FilterValueType.Multiple) {
                                   var multiFilter = cast(Type.MultipleFilterValue, filters[i]);
                                   if (!multiFilter.exclude) {
                                                   filteredMemberIds = filteredMemberIds.concat(multiFilter.values);
                                    }
                    }
    }
    
    dataAction.setParameterValue(parameterId, {
                    type: DataActionParameterValueType.Member,
                    members: filteredMemberIds
    });