Focal Point
[SOLVED] How to change what fex is run from HTML file in 8.2?

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

November 04, 2020, 12:20 PM
J.Hines
[SOLVED] How to change what fex is run from HTML file in 8.2?
We have a few custom HTML pages that have a dropdown, the value of which is a fex name. The user picks one, and presses a button to run that report. In WebFOCUS 8.1, we used a JavaScript function like this to change the ibif_ex attribute in the XML to the fex name, e.g. /WFC/Repository/MyFolder/my_stub.fex:
 
function resetRequest(rep, attr){
//for changing the attributes about what procedure to run
   var reqid = "report1";
   var myXmlRoot = loadXmlDoc();
   var pattern = "//requests/request[@requestid='" + reqid + "']";
   var requestNode = getSingleNode(myXmlRoot, pattern);
   if(requestNode) {
       requestNode.setAttribute(attr,rep);
   } else {
       alert("No request was found for request ID " + reqid + ". Be sure the reqid variable in cboReport_change() of the HTML file is set to the request ID of the Run button.");
   }
}
 


But now, in 8204, this code works, but doesn't affect what is actually run when the button is clicked anymore.

What changed? What's the new way to change what FEX is run for a particular request?

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



Prod: 8.2.0.4 OS:Windows 10 Output:AHTML, Excel 2007+

The life of a designer is a life of fight against the ugliness.
November 04, 2020, 02:44 PM
Waz
I think by that time the XML is processed and loaded into the browser.

I think there are two main options.



There are more options, an they would be more complicated.

e.g. Call a fex that returns an HTML page that runs the fex you want.


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!

November 05, 2020, 08:50 AM
J.Hines
Thanks Waz.

I'm not really sure what you mean by the first option. We give the choice to run the report as AHTML or as Excel, and deferred or immediately, but most users just use the Excel option, so there's no pane to open the report in, and in any case, my JavaScript is supposed to already be running the report chosen.

As to the second option, I was thinking of that yesterday, and need to ruminate on it a bit more, but it's complicated by the fact that we have over 50 reports, and each one of them could run 1 of 2 fexes, depending on whether the user chooses AHTML or Excel.

But for the sake of argument, do you have any sample code handy for what that "switcher fex" could look like? Right now we have a stub procedure for each report the user could pick and within that, depending on whether they chose AHTML or Excel, there's a GO TO statement with MRNOEDIT INCLUDE to run 1 of 2 fexes. Is there a way to say "INCLUDE &FEX_NAME"?



Prod: 8.2.0.4 OS:Windows 10 Output:AHTML, Excel 2007+

The life of a designer is a life of fight against the ugliness.
November 05, 2020, 03:40 PM
Waz
First option would use javascript to execute the fex in the targeted iframe. i.e. set the src of the iframe to the call for running the fex.

A switcher fex would look something like this:
-DEFAULTH &FEX_NAME = 'NONE'

-GOTO FEX_&FEX_NAME.EVAL

-*----------------------------------------------------
-FEX_NONE

-* No Fex

-GOTO Pgm_End

-*----------------------------------------------------
-FEX_SALES_RPT

-INCLUDE IBFS:/WFC/........

-GOTO Pgm_End

-*----------------------------------------------------
-FEX_SALES_CHT

-INCLUDE IBFS:/WFC/........

-GOTO Pgm_End

-*----------------------------------------------------
-Pgm_End



The last option is to return an HTML page that runs the report. This example is quite old and could be changed.

-DEFAULTH &FEX_NAME='NONE'

-IF &FEX_NAME EQ 'NONE' THEN GOTO Pgm_End ;

-*----------------------------------------------------

-HTMLFORM BEGIN
<html>
<head>
<script type=text/javascript>
document.forms.temp.submit();
}
</script>
</head>
<body onload="OnLoad()">
<form name="temp" method="get" action="/ibi_apps/WFServlet">
<input type="hidden" name="IBFS1_action" value="RUNFEX"/>
<input type="hidden" name="Rand" value="&DATE|&TOD"/>
<input type="hidden" name="IBFS_path" value="&FEX_NAME"/>
</form>
</body>
</html>
-HTMLFORM END
-*----------------------------------------------------
-Pgm_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!

November 06, 2020, 08:45 AM
MathematicalRob
This isn't what you asked for; I can't think where I've done exactly that. However, I have a number of reports with multiple forms, each executing a different task. I wonder if you could use multiple tasks to your advantage somehow. . .

 
	<tasks>
		<task id="load" trigger="load"/>
		<task id="RunMainReport" trigger="click" specifictrigger="form2Submit">
			<taskitem id="MainRequest" sourcetype="typeFex" targetname="report1" targettype="0"/>
		</task>
		<task id="RunDefault" trigger="click" specifictrigger="form4Submit">
			<taskitem id="DefaultParametersRequest" sourcetype="typeFex" targetname="report1" targettype="0"/>
		</task>
		<task id="RunFundList" trigger="click" specifictrigger="formP1Submit">
			<taskitem id="RJ0004BB-FundList" sourcetype="typeFex" targetname="report1" targettype="0"/>
		</task>
		<task id="RunPayPeriods" trigger="click" specifictrigger="formP2Submit">
			<taskitem id="RJ0004BB-PayPeriods" sourcetype="typeFex" targetname="report1" targettype="0"/>
		
</task>
 



WebFocus 8201m on Windows; App Studio 8201; Procedures: WebFocus with SQL; HTML Parameter Pages & Dashboard; Output: Excel, HTML, & PDF.
November 06, 2020, 12:33 PM
J.Hines
That's awesome, thanks. I tried the HTML option first, and got something working; at least it's able to run a fex on the reporting server from a variable name, which is cool.

But I'll probably have to go the switcher route, because once the user picks the report, they can pick Excel or AHTML output, as well as running immediately or deferred, and to me those don't seem like they would work with your HTML option.
For example, Excel deferred; not sure if that would work. At least, me changing to defer for the HTML option didn't work for me.

I like the HTML option in that it's short being that it runs the fex based on the variable, whereas the switcher would mean a long fex with a section for each report (we have like 100), but that option wouldn't really have any problem doing AHTML/Excel/Defer/Immediate, since it's all just code. But if we add a new report, we need to add a new section.

Any further comments welcome, but thank you Waz for the help and samples!



Prod: 8.2.0.4 OS:Windows 10 Output:AHTML, Excel 2007+

The life of a designer is a life of fight against the ugliness.