cancel
Showing results for 
Search instead for 
Did you mean: 

Lumira Designer Scripting question

0 Kudos

Hello,

First off, I am running Lumira Designer Version 21.0.0.

Note that the code below is a simplification of the original script I was testing, but it exhibits the same issues as the original and illustrates the issue more simply.

Quick background: in the code below, I have two data sources. I am wanting the DS_DETAIL variable selection made in line 1 of the code to be passed as an input to the same Bex variable in DS_TOTAL so that a KF in DS_TOTAL returns an updated value. I am unable to use merged prompts here because some of the data sources contain variables I do not want to be displayed when the script is launched.

When I execute the script, however, the intended behavior does not occur. The prompt screen opens, and DS_DETAIL accepts my entry properly. However, when line 4, the "debugger" line, executes, the resulting alert displays the correct variable value, but the key figure returned by the "getData" command displays an outdated value of the key figure from DS_TOTAL. If the script is executed a second time using the same Bex variable input value, all output is correct.

DS_DETAIL.openPromptDialog(300, 100);
var offering_org = DS_DETAIL.getVariableValueExt("ZCM_ORGUNIT_V12");
DS_TOTAL.setVariableValueExt("ZCM_ORGUNIT_V12", offering_org);
APPLICATION.alert(DS_TOTAL.getVariableValueExt("ZCM_ORGUNIT_V12")+","+DS_TOTAL.getDataAsString("86RCBSP2M3E6FH504BI738FLX", {}));

It seems to me that the key figure value (a sum) has not yet finished calculating when the "alert" line is executed, but I had always been under the impression, both with Design Studio and Designer, that each subsequent line of a script wouldn't execute until all previous lines had finished their necessary computing. I've used openPromptDialog in the beginning of much longer and more complicated scripts in the past without this issue. Is my assumption about how the lines of code execute behind the scenes incorrect?

In the meantime, adding lines 4-5 below seem to resolve the issue - the script now updates both the variable and the KF in DS_TOTAL properly. However, I'm still unsure why I had to add these two lines and would like to better understand what might be going on here.

DS_DETAIL.openPromptDialog(300, 100);
var offering_org = DS_DETAIL.getVariableValueExt("ZCM_ORGUNIT_V12");
DS_TOTAL.setVariableValueExt("ZCM_ORGUNIT_V12", offering_org);
DS_TOTAL.unloadDataSource();
DS_TOTAL.loadDataSource();
APPLICATION.alert(DS_TOTAL.getVariableValueExt("ZCM_ORGUNIT_V12")+","+DS_TOTAL.getDataAsString("86RCBSP2M3E6FH504BI738FLX", {}));

Can someone advise?

Thanks in advance for any help.

Accepted Solutions (0)

Answers (1)

Answers (1)

MustafaBensan
Active Contributor

Hi Scott,

When executing sequential script code related to data source manipulation, the script does not necessarily "wait" for one operation to fully complete before executing the next. This is why in scenarios such as yours, I recommend placing any code that is dependent on updates to data sources in the "On Result Set Changed" event of the corresponding data source.

I suggest you try moving the DS_TOTAL.getDataAsString("86RCBSP2M3E6FH504BI738FLX", {})) code line in your first snippet to the "On Result Set Changed" event of the DS_TOTAL data source.

Regards,

Mustafa.