Skip to Content
0

Filter Query onStartup in DesignStudio

Feb 17, 2017 at 09:17 AM

145

avatar image

Hi Experts,

I am trying to react on a query result in the startup- script. Therefore I have got a query which is restricted by an input variable (mandatory)

Within the script I set the Variable by

DS_3.loadDataSource(); 
DS_3.setVariableValueExt("TESTVAR", "123"); 
DS_3.reloadData();

var array = DS_3.getMembers("COLUMN1", 2);
array.forEach(function(element, index) {
	  POPUP_TEXT.setHtmlText(element.text);
	  POPUP_1.open();
	});

Within my forEach - Loop the result isn´t restricted. If I ignore this and look at the results in a Crosstab after startup the result is restricted.

How can I react in a startup - script on the resultset?

Thank you.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Mustafa Bensan Feb 17, 2017 at 10:13 AM
0

Hi Moritz,

You should should place your array code in the "On Result Changed" event of data source DS_3 to ensure it is executed only when the result set has been filtered and is fully available. If you put it in the "On Startup" event the loop executes before the data has finished loading.

Also, there is no need to execute the reloadData() method. Since setVariableValueExt() is executed immediately after loadDataSource(), the variable filtering should be applied together.

Regards,

Mustafa.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

One other point, if your requirement is to load the data source at startup, then why don't you simply set the Load in Script property to false and set the input variable in the "On Variable Initialization" event of the application?

0
Moritz Weber Feb 17, 2017 at 03:31 PM
0

Hi Mustafa,

thank you for your fast answer.

The solution by "on result changed" isn´t working because I must react within the onStartup coding.

The reloadData() is just for tests in the coding, also that the DS is load in the script.

Even the prompt in the forEach is for tests.

My actual requirement is to react on the resultset for example

If (number entries > 1){
   do something
}else{
   do something else
}

I think this must be done in the onStartup

Thank yor.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Moritz,

You cannot react entirely within the On Start Up event because of the need to apply your if then check after the data source with variable has been fully loaded. Also, since your requirement is to effectively react at application startup, there is actually no point in loading in script. Therefore, you should take the following approach based on my previous suggestion:

1. Set the Load in Script property of DS_3 to false

2. Apply the following code in the "On Variable Initialization" event of the application:

DS_3.setVariableValueExt("TESTVAR", "123"); 

3. Apply the following code in the "On Result Set Changed" event of data source DS_3:

if (!dataInitialized) {
	
	dataInitialized = true;	
	if (number entries > 1){
            do something
        } else {
            do something else
        }
}

dataInitialized should be defined as a Global Script Variable with a default value of false.

The above code should give the desired result effectively on startup of your application.

Regards,

Mustafa.

0