SAC Analytic Application – Scripting for Beginners : Part 2 – How-to hand over Parameters for Data Actions

In the first part of this little SAC Scripting blog series I shorty explained how Master Data can be read and changed in SAC Analytic Application with the help of scripting. In this part, I am going to show how Data Actions can be used in Analytic Application and how parameters can be dynamically defined and handed over to the data action.

As I am creating an Analytic Application to maintain the steps and activities per user, I also need to enable the user to enter steps per day as a new entry. This new entry is appended in the data model. Therefore, I create a Data Action, which is saving the entered steps.

I am reusing the User Dimension, which was described in detail in Part 1. (https://www.zpartner.eu/sac-analytic-application-scripting-for-beginners-part-1-how-to-read-and-change-master-data-of-dimensions/)

First, I need to create a Data Action with dynamic parameters. Then, I can fill these from my Analytic Application.

1.      Set up Data Action

In my case I want to enable the User to enter the Steps via an Input Field in my Analytic Application, therefore, I need a Data Action of Type ‘Advanced Formulas Step’, which adds the entered Steps for the specific User in the data model.

In this Data Action I create a Parameter for the User as a dynamic parameter.

In total, I created these parameters:

These parameters can then be easily used in Visual Formula part.

2.      Hand over Parameters

After creating the Data Action, I will now use it in my Analytic Application. To do so, I click on the plus symbol next to the Data Action in the Outline.

Fig. 5

In the Data Action of the Analytic Application, I will now add the Data Action, which was created beforehand.

The parameters, that were defined as ‘Dynamic’ in the Data Action itself, are now shown for the Data Action in the Analytic Application as well. The goal is, to let the user enter his/her steps easily in an Input Field and append these steps in the Data Model for this specific User and the selected Date.

Fig. 7

Here is the coding, which is filling the parameters and executes the data action when the User presses the OK Button.

Fig. 8

============================================================================

var steps = InputField_Steps.getValue();

var steps_numb = ConvertUtils.stringToNumber(steps);

//fill all parameters for saving the steps via the data action

var user_filter = „[User].[H1].&[“ + Var_UserID + „]“;

DataAction_2.setParameterValue(„TargetNumber“, steps_numb);

DataAction_2.setParameterValue(„TargetUser“, user_filter);

DataAction_2.setParameterValue(„TargetChallenge“,Var_ActChallenge);

DataAction_2.setParameterValue(„TargetDate“, „[Date].[YMD].&[“ + Var_Date +“]“);

DataAction_2.execute();

============================================================================

Please be aware, that every time you defined a hierarchy for your dimension, the hierarchy has to be defined in the parameter as well. This is also true for dates as the Date Dimension has a Hierarchy by default.

Now I can easily use Data Actions in my Analytic Application. I can add different calculations, which are then dynamically filling the parameters for the Data Action.

In the next part I will shortly show one way to handle and calculate with dates in the Analytic Application. Stay tuned!

Related Blogs