cancel
Showing results for 
Search instead for 
Did you mean: 

Dropdown scripts using onSelect event return incorrect key

Former Member
0 Kudos

I'm trying to make it so that the key selected in the top dropdown automatically populates the input box below:

The code is really simple, triggered by the only event available for dropdowns ("onSelect"):

session.findById("wnd[0]/usr/ctxtYPCN-PCTYPE").text =  session.findById("wnd[0]/usr/subPersonas_149796688890599/cmbPersonas_14979739727949").key;

However, the onSelect event seems to fire before the dropdown's value updates. For example, when I make my first selection, nothing happens (because it's pulling the placeholder value):

... and then when I make more selections, the script pulls the previous key:

Is there a way to get onSelect to behave as you'd expect? If not, what is the onSelect event supposed to actually be used for? Should this script be attached to onAfterRefresh instead?

Accepted Solutions (1)

Accepted Solutions (1)

Thomas_Mangler
Active Participant

Hi,

the select event offers you a variable named "newKey"

try it like this

session.findById("wnd[0]/usr/ctxtYPCN-PCTYPE").text = newKey;

best regards,

Thomas

Former Member
0 Kudos

This works, thanks. Strangely, "newKey" isn't a variable on the dropdown itself (you can't use .newKey on a dropdown id), but it works as you typed it above.

Answers (0)