cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

GetVariableValues not working at first display on view mode

Cgilb
Discoverer
0 Kudos
278

Hello Everyone,

We have a bex query with customer exit variable.
We create a new optimized story on live connection to this bex query.

We have this small script on the onActive Function of the Chart 1 :

var VariableQueryCurrentWeek = Chart_1.getDataSource().getVariableValues("XXXX")[0];
CurrentYear = cast(Type.SingleVariableValue, VariableQueryCurrentWeek).value;
console.log(CurrentYear);

(Note that is the same for : Application.getFileDataSource("CVAZVJGAC").getVariableValues("XXXX"); )

When we first launch the story in view mode we have the following error message on the console : " Cannot read properties of undefined (reading 'value') "
Which is normal as it haven't found any value for this variable even if the bex query is well filtered according to the customer exit variable.
But then when i change the page on the story and comeback to the previous one, now it is working fine.
I don't really understand what hapenned

Do you have any idea how to fix this issue and have the variable the first time we load the page in view mode ?
Thank you in advance

Best Regards

Accepted Solutions (0)

Answers (1)

Answers (1)

Vitaliy-R
Developer Advocate
Developer Advocate
0 Kudos

I am not that familiar with these APIs, but https://help.sap.com/doc/958d4c11261f42e992e8d01a4c0dde25/release/en-US/index.html#DataSource_MgetVa... suggests to use "This method may return outdated values with SAP BW dynamic filter variables. Use getDimensionFilters() instead if you are interested in their current values."

Would that work in your case?

Cgilb
Discoverer

Hello Vitaliy,
Thank you for your answer.
However this is not working.
The getDimensionFilters() only retrieved the selected story filter values and not the customer exit of the bex query.

Best Regards