Focal Point
[CLOSED] Javascript - Get Parameter from this.window.name and Use it In Fex

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/6227057296

March 02, 2020, 10:08 AM
Brandon Andrathy
[CLOSED] Javascript - Get Parameter from this.window.name and Use it In Fex
Hello,

I'm trying to automatically get the "this.window.name" function to populate in a parameter in my fex. At the moment, all I am able to do is get this to work by calling the variable via onclick. My problem is separated into two items:

1. How do I get javascript to run onload within a .fex?
2. How do I pass the variable set in javascript back to an & variable that the .fex can read?

Here's the code I'm working with so far.

 TABLE FILE CAR
HEADING
"CLICK HERE"
PRINT CAR NOPRINT
WHERE RECORDLIMIT EQ 1
ON TABLE SET PAGE NOLEAD
ON TABLE SET STYLE *
TYPE=HEADING,JAVASCRIPT=SAVEDAT(),$
ENDSTYLE
END
-RUN
-HTMLFORM BEGIN
<html>
<script language="javascript">
function SAVEDAT()
{
var usrid=parent.MyHTMLParmsPage = this.window.name;

alert(usrid);
}
</script>
</html>
-HTMLFORM END 


Thanks in Advance!!

This message has been edited. Last edited by: FP Mod Chuck,


WebFOCUS 8204
March 02, 2020, 02:36 PM
Waz
There are so many ways to do this.

Simplest (not knowing what you are trying to do) would be to move the HTML to before the report and remove the function container, just run the js.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

March 02, 2020, 09:25 PM
Brandon Andrathy
Hey Waz,

Thank you very much for your response. so if I just put this at the beginning of the report, it looks like nothing runs. Am I doing something wrong? Do I need to use a different function?

What function would I use to pass the var usrid to something WebFOCUS could read?

-HTMLFORM BEGIN
<html>
<script language="javascript">
function SAVEDAT()
{
var usrid=parent.MyHTMLParmsPage = this.window.name;

alert(usrid);
}
</script>
</html>
-HTMLFORM END 
 


Thanks in advance!


WebFOCUS 8204
March 02, 2020, 09:33 PM
Waz
Like this
-HTMLFORM BEGIN
<html>
<script language="javascript">
var usrid=parent.MyHTMLParmsPage = this.window.name;

alert(usrid);
</script>
</html>
-HTMLFORM END 



Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

March 03, 2020, 10:14 AM
Brandon Andrathy
Thank you Waz, didn’t see your point about removing the function earlier. How about reading the parameter in the .fex in WebFOCUS? Is there a function that needs to happen? I know there’s some html ibi.amp thing that you put in the code.

Is there a better way to read the current portal page other than this.window.name btw?

Thank you for your help.


WebFOCUS 8204
March 03, 2020, 03:24 PM
Waz
Here is where is get tricky.

There are possibly other ways to do it, but my suggestion for simplicity sake is to call your fex with the parameter from the HTML page, passing the name.

Something like this.

-HTMLFORM BEGIN
<html>
<script language="javascript">
window.location = '/ibi_apps//run.bip?BIP_REQUEST_TYPE=BIP_LAUNCH&|BIP_folder={IBFS Location}&|BIP_item={fexname}&|PAGENAME='+this.window.name ;
</script>
</html>
-HTMLFORM END 


The fex will get the window name in the variable &PAGENAME


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

March 05, 2020, 09:39 AM
Brandon Andrathy
Wow Waz, thank you very much for your response here. I saw another post where you talked about this briefly and I knew you knew what to do here


WebFOCUS 8204
March 05, 2020, 09:40 AM
Brandon Andrathy
I’ll try this out next week when I get back from vacation and hopefully can close this out. Appreciate it!!


WebFOCUS 8204
March 12, 2020, 10:01 PM
Hallway
quote:
<script language="javascript">


For what it's worth, language="javascript" is not a valid attribute for a script element. The proper attribute is a JavaScript MIME type like this:
 <script type="text/javascript"> 


With that said, the HTML5 specification urges authors to omit the attribute rather than provide a redundant MIME type. So that means that all you need is <script> and you're good to go.


Hallway

 
Prod: 8202M1
Test: 8202M4
Repository:
 
OS:
 
Outputs:
 
 
 
 
March 13, 2020, 02:27 PM
Hallway
quote:
call your fex with the parameter from the HTML page, passing the name


Using Waz's suggestion, you could also use an iframe by passing the variable in the uri of the iframe src, and not have to redirect the html page
  
-HTMLFORM BEGIN NOEVAL
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #report1{
            width:100vw;
            height:100vh;
        }
    </style>
</head>
<body>
    <iframe src="" frameborder="0" id="report1"></iframe>
    <script>
        const path = `/ibi_apps/run/ibfs`;
        const ibfs_path = `IBFS:/WFC/Repository/domain/fileNmae.fex`;
        const usrid = parent.MyHTMLParmsPage = this.window.name;
        const uri = `${path}?IBFS_path=${ibfs_path}&usrid=${usrid}`
        document.querySelector('#report1').src = uri;
    </script>
</body>
</html>
-HTMLFORM END

This message has been edited. Last edited by: Hallway,


Hallway

 
Prod: 8202M1
Test: 8202M4
Repository:
 
OS:
 
Outputs:
 
 
 
 
March 30, 2020, 02:49 PM
Brandon Andrathy
I never got around to being able to try this. Thank you so much for responding and for all the help here! This is awesome!


WebFOCUS 8204