Hello everyone, I am very new to SAP Analytical Cloud and need some assistance
I have a public dimension based on customers, to this, I have added the description and several properties address, phone number etc
I have then created a model that contains this dimension along with other dimensions
I wish to use the model in an Analytical Application, this I have also done applying filters etc, what I am unable to do is read the properties via a script of the customer dimension so that I can display them in a text box, it does not sound that difficult to achieve any suggestions appreciated
Thank you
Brian
Request clarification before answering.
Hi Brian,
do you want to know what properties are available (like does the customer has an attribute address?) or do you want to know the value of the property (like what is the address of the customer?)
Best regards
Viet
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I usually implement a hidden chart into my Analytic Application and add the respective dimension. The following example script gets the description for a dimension value (dimension name is MENU_KEY). Use the developer tools of Chrome to see what console.log() prints out. In the script editor of SAC, I often use CTRL+SPACE for code completion if I don't know what kind of arguments a method expects. And the API Reference is also a good place to search for answers: https://help.sap.com/doc/958d4c11261f42e992e8d01a4c0dde25/release/en-US/index.html
For starters, this blog is also good: https://www.sapanalytics.cloud/introduction-to-scripting-in-analytics-designer/

Hi Viet, thanks for your help it does return what I require
I do have 2 more questions however
Firstly in your example, you use selection[5], I have tried but I can't work out how to replace the 5 with a variable of the desired customer?
I currently have
var custsel = InputField_1.getValue();
console.log(Chart_5.getDataSource().getResultMember("Customer.PostalCode",{"Customer":selection[5].Customer}).description);
This gets the required customer number but I need the position in the array
Also, and I have not really looked at this yet, but when I use getDataSelections() it only returns 500 entries to the array?
Thanks
Brian
Hi Brian,
glad that I could be of help.
In order to find the right entry, I often loop through the array with a for-loop. Something like the following might work for you (I assume that custsel contains the customer you search for). Since I have used only low-volume datasets so far I was not aware that getDataSelections() might have a limit. In such cases, I assume that we need to filter the data source of our dummy chart first before we use getDataSelection().
for (var i = 0; i < selection.length; i++) {
if (selection[i].Customer === custsel) {
console.log(Chart_5.getDataSource().getResultMember("Customer.PostalCode",{"Customer":selection[i].Customer}).description);
}
}
You can do the following:
Add your model as a planning model to script:

Then for some button add the code:
var member=PlanningModel_1.getMember("Account","PL010");
var prop=member.properties;
console.log(prop);In this sample I am using Account dimension with the member PL010
Result you can see in F12 Console:

Account dimension has 2 properties: accType and TARGETACC
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
brian.bailey2
Unfortunately, using ResultMemberProperties API you can only get properties shown in the report table...
The code:
var prop=Table_1.getDataSource().getResultMember("Account",selection1).properties;
console.log(prop);
Will show property value only if you can see it in the report table:

Result:

The only way to get any property (not any, but most) for some member is to use PlanningModel
Create some simple planning model and test yourself
P.S. Don't ask me what is the proper name of the developer of the API like this
| User | Count |
|---|---|
| 5 | |
| 5 | |
| 4 | |
| 4 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.