Unanswered question

How do I change the value of declared variables?

I have two variables of type list (Accounts & Accounts2)
Accounts has 3 columns: login, passwd and name
Accounts2 has 2 columns: login and passwd

In the action-block I have a Javascript element with the following code:
var al = context.variableManager.getValue("Accounts2.login");
context.variableManager.setValue("Accounts.login", al);
logger.debug("al: " + al);
logger.debug("User: " + context.variableManager.getValue("Accounts.login"));

I would expect the second logger.debug to show me the account from Accounts2.login, but instead it shows me the first line from the list parameter Accounts.

How can I override the value from the list parameter Accounts with the value from Accounts2?

Sander V.
Sander V.

Sander V.

Level
0
63 / 100
points

Answers

Nouredine A.
Nouredine A.

Nouredine A.

Level
4
5000 / 5000
points
Team

You can't override the value of a variables like that. Your setValue("Accounts.login",al) will create a new variable called "Accounts.login". "login" is not a column name here.

There's maybe another way to achieve your goal so why would you like to override that value?

Sander V.
Sander V.

Sander V.

Level
0
63 / 100
points

Hi Nouredine,

Thanks for your response.
Does the application then see two variables with the same name? It does not appear to use the new variable.

According to the documentation (http://127.0.0.1:50000/en/WebHelp/#581.htm#o592) the new variable is going to be used.
"When using the name of a declared variable, a runtime variable will be created that will override the declared variable. Overriding declared variables is not recommended."

I wanted to override it because I was using the wrong type of variable (type List) first and that list contained 40 rows. I was looking for a fast way to use another list of users without having to change the script. Now I'm using the correct variable (type File)) instead :-)