Skip to Content

Screen validation with multiple transactions

Hi all,

I have a question about validating data in a field on a screen in a transaction that is different from the transaction my script was started from.

my scenario is as follows, I have a script that is started from transaction A, in this script I call transaction B, in transaction B I want to check if a specific field is blank, if it is blank, give the user a message.

Problem is the script seems to fail as it cannot recognise the field in transaction B, if I try to define this field as a variable or reference it directly .. the debugger just says the variable is undefined.

Is this even possible?

Add comment
10|10000 characters needed characters exceeded

  • Hi Steve,

    Thanks for your help. my script code is below, the transactions are in our namespace so you won't have them in your system, but that shouldn't matter, the principle should be the same I guess...

    //Declare variables
    var project = session.findById("wnd[0]/usr/cmbGV_PSPID_ANA").text;
    var work_bl = session.findById("wnd[0]/usr/txtGV_PLVERSN_WRK").text;
    var appr_bl = session.findById("wnd[0]/usr/txtGV_PLVERSN_APP").text;
    //Call transaction and set default values 
    // Input the project
    session.findById("wnd[0]/usr/ctxtS_PROJ-LOW").text = project;
    // if no factory calendar PID, calendar will be empty, message to user
    var fcal = session.findById("wnd[0]/usr/ctxtP_KALID").text;
    if (!fcal)	{
    	session.utils.alert("You do not have a default factory calendar setup in your user settings");
    } else {
    // Set default baseline version
    session.findById("wnd[0]/usr/ctxtS_PLVSN-LOW").text = appr_bl;
    // Set snapshot option defaults
    session.findById("wnd[0]/usr/chkP_ACT").selected = false;
    session.findById("wnd[0]/usr/chkP_EAC").selected = false;
    session.findById("wnd[0]/usr/chkP_REV").selected = false;
    session.findById("wnd[0]/usr/chkP_HIER").selected = false;
    session.findById("wnd[0]/usr/chkP_STAT").selected = false;
  • Which line fails?

  • var fcal = session.findById("wnd[0]/usr/ctxtP_KALID").text;
  • Get RSS Feed

5 Answers

  • Mar 21, 2017 at 08:45 PM

    Hi Neil,

    Technically speaking, there is no reason why this shouldn't work. The script does have access to the current context, so if you are referring to a field when defining a variable, it should be able to use session.findByID and a reference to the current screen's field. Perhaps the field you want to use is on a specific tab and that tab is not currently active before making the reference?

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 22, 2017 at 08:33 AM

    Hi Tamas.

    No there's no tabs. I remember in Personas 2, you had to do a screen refresh when you navigated to a new screen (or transaction) within a script otherwise the script wouldn't be able to find the control you were referencing. But I thought this wasn't necessary in Personas 3 scripting?

    Should I raise an OSS ticket?

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 22, 2017 at 04:14 PM

    There is no Refresh needed in version 3.

    Yes, I think a ticket would be best.

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 24, 2017 at 10:53 AM

    You are inputting a project code in the line:

    // Input the project
    session.findById("wnd[0]/usr/ctxtS_PROJ-LOW").text = project;

    Clearly that field is part of the new transaction. After entering that value, do you need a backend round-trip (i.e. an Enter press) to refresh the rest of the screen and pull back the values relevant to the project before the other fields are available?


    Add comment
    10|10000 characters needed characters exceeded

    • Worth a try! Not sure how much more help I can be when I can't see the transaction in question, I'm afraid. Sometimes to you just have to see it to understand what's going on. Could you record a screencam and post it, maybe? Or else just see what you get from OSS...

  • Apr 28, 2017 at 08:39 AM

    Ok, turns out the problem is related to checking if a mandatory field is blank... in Personas a mandatory field is never blank. if it's empty it still has a value of "?".

    I changed my code and it works now, although strangely the syntax checker isn't happy.

    Add comment
    10|10000 characters needed characters exceeded