Skip to Content
0

Screen validation with multiple transactions

Mar 21, 2017 at 05:17 PM

149

avatar image

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?

10 |10000 characters needed characters left characters exceeded

Posting your script, or a simplified version of it, might help in diagnosing the problem.

1

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 
session.callTransaction("/DSN/010C_PERS");
session.utils.changeFlavor("005056A03ADC1ED583CF7C7A407EF886");

// 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");
	return;
} 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;
	}



0

Which line fails?

0
var fcal = session.findById("wnd[0]/usr/ctxtP_KALID").text;
0
* Please Login or Register to Answer, Follow or Comment.

5 Answers

Tamas Hoznek
Mar 21, 2017 at 08:45 PM
0

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?

Share
10 |10000 characters needed characters left characters exceeded
Neil Ward Mar 22, 2017 at 08:33 AM
0

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?

Share
10 |10000 characters needed characters left characters exceeded
Tamas Hoznek
Mar 22, 2017 at 04:14 PM
0

There is no Refresh needed in version 3.

Yes, I think a ticket would be best.

Share
10 |10000 characters needed characters left characters exceeded
Steve Rumsby
Mar 24, 2017 at 10:53 AM
0

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?

Steve.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hi Steve and thanks for taking the time to help.

I tried the enter trick just in case it was the issue, but it's not, in fact that field is already visible on the screen and its a mandatory field, so the script stops at this point if the field is empty and gives the user the standard "fill in all required entry fields" message. I'm trying to avoid the user seeng this screen and this message and instead see my message and not even get to the next screen.

I think I will open an OSS ticket.

0

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...

0
Neil Ward Apr 28, 2017 at 08:39 AM
0

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.


error-checker.png (178.5 kB)
Show 2 Share
10 |10000 characters needed characters left characters exceeded

You need double = like

if (fcal == "?" ) {
0

rookie mistake, you can tell I'm not a Javascript coder :)

0