cancel
Showing results for 
Search instead for 
Did you mean: 

Screen validation with multiple transactions

smith_john
Active Participant
0 Kudos

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?

Former Member

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

smith_john
Active Participant
0 Kudos

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;
	}



Former Member
0 Kudos

Which line fails?

smith_john
Active Participant
0 Kudos
var fcal = session.findById("wnd[0]/usr/ctxtP_KALID").text;

Accepted Solutions (0)

Answers (5)

Answers (5)

smith_john
Active Participant
0 Kudos

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.

tamas_hoznek
Product and Topic Expert
Product and Topic Expert
0 Kudos

You need double = like

if (fcal == "?" ) {
smith_john
Active Participant
0 Kudos

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

Former Member
0 Kudos

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.

smith_john
Active Participant
0 Kudos

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.

Former Member
0 Kudos

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

tamas_hoznek
Product and Topic Expert
Product and Topic Expert
0 Kudos

There is no Refresh needed in version 3.

Yes, I think a ticket would be best.

smith_john
Active Participant
0 Kudos

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?

tamas_hoznek
Product and Topic Expert
Product and Topic Expert
0 Kudos

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?