on 09-20-2016 12:53 PM
Hello,
I try to create "dynamic fields" on a Personas screen.
I want that users choose the imputation type (order, Cost Center, WBS) and automatically a script linked to this element is executed to display some fields and hide others.
I created the script :
// Affichage zone de l'imprimante
var type_imput = session.findById("wnd[0]/usr/cmbPersonas_147375328940490").key;
// affichage du type d'imputation dans la zone de contrôle
//session.findById("wnd[0]/usr/txtPersonas_147375727811020").text = type_imput;
// affichage/masquage de zone
if (type_imput == 'P')
{
session.findById("wnd[0]/usr/ctxtPersonas_147341959652946").show() //otp
session.findById("wnd[0]/usr/lblPersonas_147341959652885").show()
session.findById("wnd[0]/usr/lblPersonas_147341960679085").hide()
session.findById("wnd[0]/usr/ctxtPersonas_147341960679080").hide()
session.findById("wnd[0]/usr/lblPersonas_14734196220566").hide()
session.findById("wnd[0]/usr/ctxtPersonas_147341962205784").hide()
}
else if (type_imput == 'K')
{
session.findById("wnd[0]/usr/ctxtPersonas_147341959652946").hide()
session.findById("wnd[0]/usr/lblPersonas_147341959652885").hide()
session.findById("wnd[0]/usr/lblPersonas_147341960679085").show()
session.findById("wnd[0]/usr/ctxtPersonas_147341960679080").show()
session.findById("wnd[0]/usr/lblPersonas_14734196220566").hide()
session.findById("wnd[0]/usr/ctxtPersonas_147341962205784").hide()
}
else if (type_imput == 'F')
{
session.findById("wnd[0]/usr/ctxtPersonas_147341959652946").hide()
session.findById("wnd[0]/usr/lblPersonas_147341959652885").hide()
session.findById("wnd[0]/usr/lblPersonas_147341960679085").hide()
session.findById("wnd[0]/usr/ctxtPersonas_147341960679080").hide()
session.findById("wnd[0]/usr/lblPersonas_14734196220566").show()
session.findById("wnd[0]/usr/ctxtPersonas_147341962205784").show()
}
and linked it to the event "on select" of my "drop down list" field.
The script works fine when I execute it "manually" from the script menu but when I execute it from the screen (as an end-user), the value of my variable "type_imput" is always the old value (not the value choose by the user but the value before the choice).
I found this information on the "SAP Personas - Scripting API Documentation" but I have no idea how I can use this function. I tried some variantes but unsuccessful. I found'nt example or other documentation about this topic.
This event is fired when the dropdown listbox's selected value is changed by the user. If the associated script returns a Boolean true value, then the event propagation is stopped and the backend is not informed that the selection event was raised on the client and the dropdown listbox's displayed, selected value reverts to its pre-selection value. If the script returns anything else ('undefined', 'null', an object, a string, etc.), then the event processing continues normally. Note: Within the handler script, "source.key" is the old key, the one that was selected before the selection was changed triggering the current onSelect event. "newKey" represents the key that was just selected.
Have somebody experiences or examples, how to use the "newkey" value for scripting ?
Thanks for your help
Dominique
var type_imput = session.findById("wnd[0]/usr/cmbPersonas_147375328940490").key;
This wil not have the updated newkey.
Lines from the scripting API documentation
"Note: Within the handler script, "source.key" is the old key, the one that was selected before the selection was changed triggering the current onSelect event. "newKey" represents the key that was just selected. This event is fired when the dropdown listbox's selected value is changed by the user. "
so in your case, just do:
var type_input = newKey;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
I tried with different sentences but never with success 😞
I tried with :
var type_imput = newKey;
and I have this error :
Error during script execution:
'newKey' is undefinedReferenceError: 'newKey' is undefined
at Function code (Function code:5:1)
at self.executeScriptInternal (https://gessapdev2.skyguide.corp/sap/bc/personas3/core/script/sap/personas/fw/its/scripting/Scriptin...)
at sap.personas.scripting.executeScriptInternal (https://gessapdev2.skyguide.corp/sap/bc/personas3/core/script/sap/personas/fw/its/scripting/Scriptin...)
at Anonymous function (eval code:1:594)
and when I tried with :
var type_imput = session.findById("wnd[0]/usr/cmbPersonas_147375328940490").newKey;
I have no error, ... but the script doesn't work (nothing is happening)
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.