Use Data Actions Technical Objects

Besides the Data Action Trigger widget, as an application designer you can also use the Data Actions technical object and related script APIs to let application users perform data actions, set and read parameter values at runtime.

Prerequisites

Before you can use the data actions technical object, 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 read permission for it.
  • To execute a data action, you need the execute permission for it.

Context

Data action is a flexible planning tool for making structured changes to a version of model data, such as copying data from one model to another. In analytics designer there are two ways for you to utilize this feature:
  • using the Data Action Trigger widget and related APIs

    For how to add a data action trigger to your analytic application and configure related settings, refer to Set Up Planning Triggers.

  • using the Data Actions technical object and related APIs

    You can do the following:
    • setting the value for a data action paramenter

    • reading the value of the data action parameter

    • executing the data action

Procedure

  1. In the Scripting section of the Outline panel, select right next to Data Actions to add a data actions technical object.

    The side panel Data Action Configuration opens.

  2. From 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 choosing the given default value that has been set in the data action designer.
    Note
    • To execute a data action successfully, you need to enter the values of all parameters, either in Data Action Configuration panel or via the API setParameterValue.

    • The design of the data action itself can't be changed in Data Action Configuration, but you can adjust the data action by seting parameter values there.

  4. Select Done.
  5. After adding the technical object, you can leverage the following APIs to work with data actions in your application:
    • executing data actions

      execute(): DataActionExecutionResponse;;

    • getting parameter values

      getParameterValue(parameterId: string): DataActionParameterValue;

    • setting parameter values

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

      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
      });