Conditional editing for output fields?

Use this board to ask questions or have discussions with other Genie users.
rmarsh
Profound User
Posts: 56
Joined: Tue Jan 20, 2015 4:28 pm
First Name: Raymond
Last Name: Marsh
Company Name: Cracker Barrel Old Country Sto
Phone: 615-235-4215
Address 1: PO Box 787
City: Lebanon
State / Province: Tennessee
Zip / Postal Code: 37088
Country: United States
Contact:

Conditional editing for output fields?

Post by rmarsh »

One can replace the value property of an output field with a static value such as "Master Files"
The issue is on a dynamic menu where the value can change I cannot simply use a static value. What I would like to do is change "Master Files.........." to "Master Files" by somehow removing the ".........."

Can this be done?

Thanks.
User avatar
Alex
Profound Logic Staff Member
Posts: 233
Joined: Fri Jan 04, 2008 12:10 pm
First Name: Alex
Last Name: Roytman
Company Name: Profound Logic Software
Contact:

Re: Conditional editing for output fields?

Post by Alex »

On a specific field and property, you can specify "js:" or "script:" followed by a JavaScript expression. For example, the following replaces all dots in a field with empty spaces:

Code: Select all

js: value.replace(/\./g, "");
If you need to do this globally on a screen (or on all screens within an application), you could write a script to loop through all fields on the screen and do the replacement. This would normally go into your custom.js file. The code for something like that would look as follows:

Code: Select all

var fields = getOutputFields();
for (var i = 0; i < fields.length; i++) {
  var field = fields[i];
  var value = get(field.id);
  value = value.replace(/\./g, "");
  pui.set(field.id, value);
}
rmarsh
Profound User
Posts: 56
Joined: Tue Jan 20, 2015 4:28 pm
First Name: Raymond
Last Name: Marsh
Company Name: Cracker Barrel Old Country Sto
Phone: 615-235-4215
Address 1: PO Box 787
City: Lebanon
State / Province: Tennessee
Zip / Postal Code: 37088
Country: United States
Contact:

Re: Conditional editing for output fields?

Post by rmarsh »

That worked great. I entered the second example code in the onload property of the screen. Is that the best way to do this?
User avatar
Alex
Profound Logic Staff Member
Posts: 233
Joined: Fri Jan 04, 2008 12:10 pm
First Name: Alex
Last Name: Roytman
Company Name: Profound Logic Software
Contact:

Re: Conditional editing for output fields?

Post by Alex »

Putting into the onload event should work without problems.

But if you needed to make this reusable for other screens, you could put the code into cusotm.js as a function, like this:

Code: Select all

function replaceDots() {
  var fields = getOutputFields();
  for (var i = 0; i < fields.length; i++) {
    var field = fields[i];
    var value = get(field.id);
    value = value.replace(/\./g, "");
    pui.set(field.id, value);
  }
}
The in the onload event, you would simply specify:

Code: Select all

replaceDots();
Your custom.js file is located in the following IFS directory: /www/profoundui/htdocs/profoundui/userdata/genie skins/[The Name Of Your Skin]
rmarsh
Profound User
Posts: 56
Joined: Tue Jan 20, 2015 4:28 pm
First Name: Raymond
Last Name: Marsh
Company Name: Cracker Barrel Old Country Sto
Phone: 615-235-4215
Address 1: PO Box 787
City: Lebanon
State / Province: Tennessee
Zip / Postal Code: 37088
Country: United States
Contact:

Re: Conditional editing for output fields?

Post by rmarsh »

Thanks again Alex.

I am noticing some changes in areas where there are no dots. For example text fields that were centered are now left justified. As if the spaces were removed. Also, the sub-file border only in the center of the screen went from solid blocks to underscores.
Before replacedots
Before replacedots
InfiniumBeforeNoDots.JPG (73.95 KiB) Viewed 5151 times
After replacedots
After replacedots
InfiniumAfterNoDots.JPG (88.67 KiB) Viewed 5151 times
User avatar
Alex
Profound Logic Staff Member
Posts: 233
Joined: Fri Jan 04, 2008 12:10 pm
First Name: Alex
Last Name: Roytman
Company Name: Profound Logic Software
Contact:

Re: Conditional editing for output fields?

Post by Alex »

Our get() API trims blanks spaces. Try using getElementValue() instead of get(). That should not trim the spaces.

Here are the docs for these API:
http://www.profoundlogic.com/docs/displ ... %28+id+%29
http://www.profoundlogic.com/docs/displ ... %28+id+%29
rmarsh
Profound User
Posts: 56
Joined: Tue Jan 20, 2015 4:28 pm
First Name: Raymond
Last Name: Marsh
Company Name: Cracker Barrel Old Country Sto
Phone: 615-235-4215
Address 1: PO Box 787
City: Lebanon
State / Province: Tennessee
Zip / Postal Code: 37088
Country: United States
Contact:

Re: Conditional editing for output fields?

Post by rmarsh »

Thanks again Alex.

It is still doing the same thing. I've played around with various methods and I can get js to replace a '.' with a space in a string but not in 5250 output field. I don't know why the behavior is different. It still is replacing leading blanks and changing part of the subfile boundry. Those areas have no dots so I'm not sure what is going on there.
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: Conditional editing for output fields?

Post by Scott Klement »

Ray, can you post your modified version of replaceDots() so we can see what it looks like now?
rmarsh
Profound User
Posts: 56
Joined: Tue Jan 20, 2015 4:28 pm
First Name: Raymond
Last Name: Marsh
Company Name: Cracker Barrel Old Country Sto
Phone: 615-235-4215
Address 1: PO Box 787
City: Lebanon
State / Province: Tennessee
Zip / Postal Code: 37088
Country: United States
Contact:

Re: Conditional editing for output fields?

Post by rmarsh »

The "if" statement is to target only specific output fields on the screen. I'm not sure it is still necessary but this is working.

Code: Select all

function replaceiDots() {
  var fields = getOutputFields();
  for (var i = 0; i < fields.length; i++) {
    var field = fields[i];
    var str = field.id;
    if ((str.split("_")[2] == "43") || (str.split("_")[2] == "4")) {
      fields[i].innerHTML=fields[i].innerHTML.replace(/\&nbsp;\./mgi,"&nbsp;&nbsp;");
    }
  }
}
User avatar
Alex
Profound Logic Staff Member
Posts: 233
Joined: Fri Jan 04, 2008 12:10 pm
First Name: Alex
Last Name: Roytman
Company Name: Profound Logic Software
Contact:

Re: Conditional editing for output fields?

Post by Alex »

It's not apparent to me what the problem might be. It seems like your version of the code should work. Perhaps you could post a JSON capture of your screen here, so that we can try it on our system. To get the capture, navigate to the screen and press Ctrl-F9. Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest