multiStepAction - reading element value

Use this board to ask questions or have discussions with other Genie users.
Post Reply
SrinivasSiripuram
New User
Posts: 14
Joined: Wed Feb 26, 2020 4:24 pm
First Name: Srinivas
Last Name: Siripuram
Company Name: UPMC
Phone: 2015655901
Address 1: 532 Chatham Park Dr, APT 2A
Address 2: Pittsburgh
City: Pittsburgh
State / Province: Pennsylvania
Zip / Postal Code: 15220
Country: United States
Contact:

multiStepAction - reading element value

Post by SrinivasSiripuram »

Hi Team,

I am using multiStepAction to do some actions across multiple Genie screens. I am using the below code.

submitButton.addEventListener("click",function(){
var profileId = document.getElementById('input1').value;
var numberOfLines = document.getElementById('input2').value;

var lineInput;
var steps = [];

for(i=1; i<=numberOfLines;i++){
if(i==1){lineInput = 1;} else { lineInput = 2;}
steps.push("changeElementValue('I_20_11', '" + lineInput + "'); pressKey('f10')");
steps.push("changeElementValue('I_13_52', '" + profileId + "'); pressKey('Enter')");
steps.push("pressKey('f2')");
multiStepAction(steps);
}
});


The above code is working fine, but i have requirement to read one element value in the second screen(in step 2) and i want use that element value in the third screen(third Step).

Can someone please help how to read the element value in the second step and use it in the third step or so.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: multiStepAction - reading element value

Post by Scott Klement »

One idea is to create a global variable. When it is on the 2nd screen, use the get() API to set the global variable, and on the 3rd screen, set the appropriate field to the global variable.

For example, assuming the ID of the widget on screen2 is 'X_X_X' and the ID of the one you want to set on screen3 is 'I_Y_Y' then you could do the following:

Code: Select all

submitButton.addEventListener("click", function() {
   var profileId = document.getElementById('input1').value;
   var numberOfLines = document.getElementById('input2').value;

   var lineInput;
   var steps = [];
   if (typeof window.global === "undefined") window.global = {};

   for(i=1; i<=numberOfLines;i++){
      if(i==1){lineInput = 1;} else { lineInput = 2;}
      steps.push("changeElementValue('I_20_11', '" + lineInput + "'); pressKey('f10')");
      steps.push("changeElementValue('I_13_52', '" + profileId + "'); global.savedVal = get('X_X_X'); pressKey('Enter')");
      steps.push("changeElementValue('I_Y_Y', global.savedVal); pressKey('f2')");
      multiStepAction(steps);
   }
});
SrinivasSiripuram
New User
Posts: 14
Joined: Wed Feb 26, 2020 4:24 pm
First Name: Srinivas
Last Name: Siripuram
Company Name: UPMC
Phone: 2015655901
Address 1: 532 Chatham Park Dr, APT 2A
Address 2: Pittsburgh
City: Pittsburgh
State / Province: Pennsylvania
Zip / Postal Code: 15220
Country: United States
Contact:

Re: multiStepAction - reading element value

Post by SrinivasSiripuram »

Hi Scott,

Thank you so much for the quick response, i have tried the way you have suggested, its not working, i am always getting global.savedVal value undefined.
I am suspecting "global.savedVal = get('D_6_10')" this statement is not assigning value to global.savedVal.

Can you please help us suggesting, if you have any other approach.

Below is the code which i have tried.

submitButton.addEventListener("click",function(){
var profileId = document.getElementById('input1').value;
var numberOfLines = document.getElementById('input2').value;

var lineInput;
var steps = [];

if (window.global === undefined)
window.global = {};

for(i=1; i<=numberOfLines;i++){
if(i==1){lineInput = 1;} else { lineInput = 2;}
steps.push("changeElementValue('I_20_11', '" + lineInput + "'); global.savedVal = get('D_6_10'); pressKey('f10')");
console.log("reading value ", window.global.savedVal);
console.log("reading value1 ", global.savedVal);
steps.push("changeElementValue('I_13_52', '" + profileId + "'); pressKey('Enter')");
steps.push("pressKey('f2')");
steps.push("changeElementValue('I_22_25', global.savedVal); pressKey('Enter')");
multiStepAction(steps);
}

});
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: multiStepAction - reading element value

Post by Scott Klement »

Hello,

This code is wrong:

Code: Select all

  if (window.global === undefined)
    window.global = {};
That's not how you check if something is undefined. it should be as I posted earlier:

Code: Select all

  if (typeof window.global === "undefined")
    window.global = {};
Also, these two lines do not make sense:

Code: Select all

    console.log("reading value ", window.global.savedVal);
    console.log("reading value1 ", global.savedVal);
You are printing these at the time you are creating your array of steps. The code in the array hasn't be run yet, so you can't check the values of the code at this time. They are not run until during the execution of the multiStepAction().

Think of it this way: First, you are writing some source code and putting it into character strings. Then, you are executing that code later during the multiStepAction. You can't check the values of the variables at the time you are building the source code because it hasn't been run yet. You have to check the values when they are run.

Also, the two lines (if they worked) do the same thing... window.global.savedVal is the same thing as global.saveVal. So why do it twice?

If you want to insert console logs of the values, it would be done like this:

Code: Select all

  for(i=1; i<=numberOfLines;i++){
    if(i==1){lineInput = 1;} else { lineInput = 2;}
    steps.push("changeElementValue('I_20_11', '" + lineInput + "'); global.savedVal = get('D_6_10'); console.log("read val: " + global.savedVal); pressKey('f10')");
    steps.push("changeElementValue('I_13_52', '" + profileId + "'); pressKey('Enter')");
    steps.push("pressKey('f2')");
    steps.push("changeElementValue('I_22_25', global.savedVal); console.log("set val: " + global.savedVal); pressKey('Enter')");
  }
  multiStepAction(steps);
Notice that in my version, the console.log() calls are inside the strings being added to the steps array. This is what I mean by source code. If you viewed 'steps' after the loop (before the multiStepAction) you'd see that it is just code... it hasn't been run yet.

Also, the multiStepAction() call should not be inside the loop. You don't want to run the code multiple times, do you? At least, not if I understand it correctly... (Which I may not... I'm not familiar with your screens.)
SrinivasSiripuram
New User
Posts: 14
Joined: Wed Feb 26, 2020 4:24 pm
First Name: Srinivas
Last Name: Siripuram
Company Name: UPMC
Phone: 2015655901
Address 1: 532 Chatham Park Dr, APT 2A
Address 2: Pittsburgh
City: Pittsburgh
State / Province: Pennsylvania
Zip / Postal Code: 15220
Country: United States
Contact:

multiStepAction is not working in Rich Display File

Post by SrinivasSiripuram »

Hi Team,

MultiStepACtion is not working in Rich Display file screens, can some one please help how to achive.

Below is my sample code:

var steps = [];
steps.push("pui.click('linkCF09'); console.log('first step')");
steps.push("console.log('second step'); pui.click('linkCF04')");
steps.push("changeElementValue('IX2BECAT', '99R'); console.log('Third Step')");
multiStepAction(steps);


In the above code only first step is working, second step onwards its not working.

In Rich display file pressKey function is not working, so i am using pui.click().

instead of pressKey('f9') --> i am using pui.click('linkCF09').
instead of pressKey('f4') --> i am using pui.click('linkCF04').
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: multiStepAction - reading element value

Post by Scott Klement »

Hi,

multiStepAction is for working with Genie screens (5250 screens) rather than Rich Displays.

For Rich Displays people don't typically need or use something like this. You could potentially do something similar with standard JavaScript, but you'd need to code it on a per-screen basis.
SrinivasSiripuram
New User
Posts: 14
Joined: Wed Feb 26, 2020 4:24 pm
First Name: Srinivas
Last Name: Siripuram
Company Name: UPMC
Phone: 2015655901
Address 1: 532 Chatham Park Dr, APT 2A
Address 2: Pittsburgh
City: Pittsburgh
State / Province: Pennsylvania
Zip / Postal Code: 15220
Country: United States
Contact:

Re: multiStepAction - Rich Display File

Post by SrinivasSiripuram »

Hi Scott,

Thank you so much for the quick response.

we have requirement to create script, that script needs to access the next screen elements, can you please suggest is there any way in Profound/JavaScript for Rich Display file screens to access the next screen elements like multiStepAction api.
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests