Focal Point
[SOLVED]WF 8009 Multiple Output formats for one self-serve report

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

February 20, 2017, 09:55 AM
Michele Brooks
[SOLVED]WF 8009 Multiple Output formats for one self-serve report
I have the following javascript code that determines which output format to enable depending on the report that is selected in the self-serve page. I need to know how to get this code working so that when the user selects PDF or EXL07, it will run for the correct output format. Right now, when I select either PDF or EXL07 radio buttons, the report only displays in PDF format. Thanks.

 
//* Enable Output formats PDF and EXL07.  Disable all other radio buttons
       if ((reportselected ==  'ss_p0001_report1.fex') ||
            (reportselected == 'ss_p0002_report2.fex' ||
            ( reportselected == 'ss_p0003_report3.fex') || 
            (reportselected == ss_p0004_report4.fex'))
       {
       document.getElementById("radiopdf").disabled = false;
       document.getElementById("radioexl07").disabled = false;
       document.getElementById("radioexl2k").disabled = true;
       document.getElementById("radiohtml").disabled = true;
       document.getElementById("radioppt").disabled = true;
       document.getElementById("checkbox1_0").disabled = false;
       document.getElementById("checkbox2_0").disabled = false;
      document.getElementById("checkbox3_0").disabled = false;
       document.getElementById("listbox6").disabled    = false;
      document.getElementById("listbox7").disabled    = false;
      document.getElementById("listbox8").disabled    = false;
       document.getElementById("calendar1").disabled   = false;
      document.getElementById("calendar2").disabled   = false;
       }


WF 8009
Windows 7



 

This message has been edited. Last edited by: Michele Brooks,


WF 8205, Windows 10
Oracle DBMS
EXL07/PDF Output
February 20, 2017, 01:28 PM
Squatch
Michele, this might be easier than you think.

Try this:

-DEFAULT &WFFMT='XLSX';

TABLE FILE ibisamp/CAR
  PRINT COUNTRY MODEL CAR
  ON TABLE PCHOLD FORMAT &WFFMT.(<HTML,HTML>,<PDF,PDF>,<Excel XLSX,XLSX>,<HTML Active Report,AHTML>).Select type of display output.
END

If you are using something like App Studio, the WFFMT amper variable should be seen by the HTML composer tool and you'll be given a chance to have a user control created automagically. This is one feature of WebFOCUS that I really like a lot.

I know this works because I have created a self-serve application that does what you seem to be trying to do.


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
February 20, 2017, 01:28 PM
MartinY
It seems that you have multiple control to manage the output format where, I think, you should have only one control since it's to assign one output value (variable).

One variable (control) that will have multiple options (values) and from which the user will select the output format.

Now you have 5 radio (control) : radioexl07, radioexl2k, radiohtml, radiopdf, radioppt. Create one control with 5 options instead.
_____________

Squatch option will work but you won't have control on which option to display as you requested.

With one control having multiple options, you can then control which one to display or not using js or jquery.


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
February 20, 2017, 01:42 PM
Squatch
quote:
Originally posted by MartinY:
Squatch option will work but you won't have control on which option to display as you requested.

You mean you can't set an output format user control using JavaScript, especially when IBI provides such functionality?


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
February 20, 2017, 01:49 PM
MartinY
quote:
You mean you can't set an output format user control using JavaScript, especially when IBI provides such functionality?


No, I mean that with format auto-prompting (except if there is a way that I'm not aware of) you cannot control "dynamically" based on another selection, which output format will be displayed : you select once which format you want to be available and it will be the same choices all the time.

Michele is requesting:
quote:
determines which output format to enable depending on the report that is selected

which I don't think is possible using auto-prompting.

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


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
February 20, 2017, 02:08 PM
Squatch
quote:
Originally posted by MartinY:
quote:
You mean you can't set an output format user control using JavaScript, especially when IBI provides such functionality?


No, I mean that with format auto-prompting (except if there is a way that I'm not aware of) you cannot control "dynamically" based on another selection, which output format will be displayed : you select once which format you want to be available and it will be the same choices all the time.

Here's the complete code.

Fex (again):

-DEFAULT &WFFMT='XLSX';

TABLE FILE ibisamp/CAR
  PRINT COUNTRY MODEL CAR
  ON TABLE PCHOLD FORMAT &WFFMT.(<HTML,HTML>,<PDF,PDF>,<Excel XLSX,XLSX>,<HTML Active Report,AHTML>).Select type of display output.
END

Using App Studio, I created a new HTML page. I told it the data source was the fex file shown above. I told HTML composer to go ahead and create a single layer form control for the WFFMT amper variable. It very helpfully read the fex and created a radio control to allow the user to select an output format of HTML, PDF, Excel or Active Report (It even put output format icons in the control... e.g., the Excel choice has the Excel logo next to it). The ID of the control was "radio1".

It also created a submit button. I clicked once on the submit button, then went to "Properties" and clicked on the "Click" event for this submit button. This gave me a chance to run some JavaScript code before the fex ran:

function form1Submit_onclick(event) {
   var arr = [];
   arr[0] = 'PDF';


   IbComposer_setCurrentSelection('radio1', arr, false);
}


I set up an array of one and used that in the IBI function that programmatically allows a user control to be reset to another value. Since the fex defaults to Excel, so did the control. I had the IBI function change it to PDF at the last possible moment before the fex was run. The test run produced a PDF file, and afterward the control showed "PDF" for the selection.

All Michele needs to do is replace my code to reset the output control with whatever logic she requires to determine what the report output should be.


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
February 20, 2017, 02:20 PM
Squatch
By the way, if Michele finds it necessary for the user to see what the output format will be BEFORE the submit button is clicked, there is nothing to prevent her from calling a "reset" function after the user changes any control that might affect the output format. This reset function would look at all the user controls as variables and reset the output format. It would need to be called after every control is changed that is such a variable.


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
February 20, 2017, 02:34 PM
MartinY
It's nice Squatch what you did.
This is a good way if you want to force a specific output but it doesn't give the user a choice of output format; except if I misunderstood your scenario.

What I understood from Michele's request is to have this ability (as an example):

- If reportA then display available output format choices : Exl07, Exl2k and PDF
- If reportB then display available output format choices : Exl07 and HTML
- If reportC then display available output format choices : Exl07, Exl2k, HTML, PPT and PDF

And this is possible with a dynamic control, not with using format auto-prompting (AFAIK).


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
February 20, 2017, 02:52 PM
Squatch
Okay, that's a tad bit insane but I can see where you can interpret the request that way.

If that's what Michele is really interested in, then not enough information has been provided. We don't know what is or is not being sent to the report. Only that PDF is being generated.


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
February 20, 2017, 02:59 PM
Squatch
I think this is a good case for needing these two lines at the beginning of the report fex in question:

-? &
-EXIT



App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
February 20, 2017, 03:15 PM
Squatch
If I had to deal with this, I would have a JavaScript function that fires every time a user changes a control that affects the output format choices. The function would determine what the new choices are and repopulate a dropdown control. The user would then select one of the valid output choices from this dropdown select. The dropdown would be tied to the WFFMT amper variable in the report.


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
February 20, 2017, 03:30 PM
MartinY
quote:
If that's what Michele is really interested in, then not enough information has been provided. We don't know what is or is not being sent to the report. Only that PDF is being generated.


I think that the "no matter what" PDF format is generated it's due to the order the variables are received in the fex.
Probably the report's format applied is the last one received (based on assumption that one control exist per output type).

quote:
If I had to deal with this, I would have a JavaScript function that fires every time a user changes a control that affects the output format choices. The function would determine what the new choices are and repopulate a dropdown control. The user would then select one of the valid output choices from this dropdown select. The dropdown would be tied to the WFFMT amper variable in the report.

This is what I would do or use js (or jquery) to manage a radio control output format options.


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
February 20, 2017, 03:31 PM
WFDevConsultant
You can do that by finding the request id. You need to update the filename for the request id based on your selection.


8.2.06
Windows, All Formats
February 21, 2017, 09:42 AM
Michele Brooks
Squatch: The output format radio buttons were originally one button. The reason why I separated the radio buttons is because if the user selects report1, for example, I want them to have the capability of choosing only 2 output formats, PDF or EXL07. So when they select report1, I want only PDF & Excel radio buttons enabled and the other 3 output format radio buttons disabled. Although in report1 fex the default output format is PDF, but I want the user to be able to also select Excel output format from the self-serve page and have the report display in Excel format. Currently, when I enable both PDF and Excel output format radio buttons in the self-serve page and select the Excel format radio button, the report still displays in PDF format. I need a way to override the default PDF output format that's coded in report1 fex whenever the user selects Excel format. This is what I need to fix. Thanks for all of the comments from everybody.

This message has been edited. Last edited by: Michele Brooks,


WF 8205, Windows 10
Oracle DBMS
EXL07/PDF Output
February 21, 2017, 10:50 AM
MartinY
So Michele, this is exactly what Squatch and myself suggesting you.

You need one and only one control. Not multiple control that defines available output format.

You can either create a drop downs list that will list the available options that will also be managed dynamically (according to report selected by the user) as per Squatch has previously suggested or as I suggest, use one radio where you will show/hide options according to report selected by the user.

Both solutions will work, your choice.
But having multiple controls to in fact manage one "variable" (the output type) is not the better way.
It's not that it's not feasible, but you will need much more code IMHO.


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
February 21, 2017, 11:06 AM
Michele Brooks
Thanks for the clarification. Not sure what you mean by IMHO. When it comes to extensive or more complex coding in self-serve pages, I'm a novice. If you get a chance, can you send me an example of how I can show/hide the output formats for one radio button based on a report selected? Thanks so much.


WF 8205, Windows 10
Oracle DBMS
EXL07/PDF Output
February 21, 2017, 12:05 PM
MartinY
IMHO - in my humble opinion

I look what I can do to provide a simple example.


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
February 21, 2017, 01:07 PM
j.gross
I presume the Report fex files expect a parameter (e.g., &WFFMT) to specify the requested format.

If the control for the format selection were a drop-down list, you could simply chain it to the report-choice control, and have a fex use the Selected Report parameter to return the list of formats available for the selected report in XML format -- without any JS footwork.


- Jack Gross
WF through 8.1.05
February 21, 2017, 01:24 PM
Michele Brooks
j.gross, the issue with this choice is that we don't want to give control of the output format to the users. For example, we want to output all html composer fexes that we create to PDF format. The users won't be aware of that and may choose Excel format in the drop-down list. We want to control up front what output format(s) to assign to each report selected. My issue is when the same report can have multiple output formats. Thanks for the suggestion.


WF 8205, Windows 10
Oracle DBMS
EXL07/PDF Output
February 21, 2017, 01:39 PM
j.gross
I don't see the issue.

If report A supports only PDF, then (if you rig the fex to populate the format choice correctly) PDF will be the only option presented when the user selects report A.

If report B supports PDF and Excel, then those two will be the options available in the drop-down when the user selects report B.


- Jack Gross
WF through 8.1.05
February 21, 2017, 01:53 PM
MartinY
In a js function, here a atarting point.
With Google search you can find a lot of sample and code.
function reportSelect_onchange(event) {
    if (reportSelect0.checked == true || reportSelect1.checked == true)
    {
        outputOpt0.style.visibility='visible';
        outputOpt_LABEL_0.style.visibility='visible';
        outputOpt1.style.visibility='hidden';
        outputOpt_LABEL_1.style.visibility='hidden';
        outputOpt0.checked = true;
    }


Where each outputOpt(n) is a radio option for the output format

To create a fex as j.gross suggest, here one way from the many ones available with WF

1- Create a text file (which I saved in baseapp) with the data such as
RPTCD,OPUTCD,OPUTFMT
RPT1,PDF,PDF
RPT1,EXL2K,Excel 2000
RPT1,EXL07,Excel 2007
RPT1,HTML,HTML
RPT1,PPT,PowerPoint
RPT2,PDF,PDF
RPT2,EXL07,Excel 2007
RPT2,HTML,HTML
RPT3,PDF,PDF
RPT3,EXL2K,Excel 2000
RPT3,HTML,HTML
RPT3,PPT,PowerPoint
RPT4,HTML,HTML

2- Generates the associated master file (note that my fisrt row is the field header)
.mas:
FILENAME=RPTFMTOPT, SUFFIX=DFIX    ,
 DATASET=E:\ibi\apps\baseapp\rptfmtopt.txt, $
  SEGMENT=RPTFMTOPT, SEGTYPE=S0, $
    FIELDNAME=RPTCD, ALIAS=RPTCD, USAGE=A4, ACTUAL=A4B,
      TITLE='RPTCD', $
    FIELDNAME=OPUTCD, ALIAS=OPUTCD, USAGE=A5V, ACTUAL=A5BV,
      TITLE='OPUTCD', $
    FIELDNAME=OPUTFMT, ALIAS=OPUTFMT, USAGE=A10V, ACTUAL=A10BV,
      TITLE='OPUTFMT', $

.acx:
SEGNAME=RPTFMTOPT,
  DELIMITER=',',
  HEADER=YES, $

3- Create the fex that will provide data for the output list
TABLE FILE RPTFMTOPT
BY RPTCD
BY OPUTCD
BY OPUTFMT
ON TABLE PCHOLD FORMAT XML
END
-RUN

The solution is not complete, you still need to add some code and perform some research on how to complete it.

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


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
February 21, 2017, 02:11 PM
j.gross
#3 should be along the lines of...

TABLEF FILE RPTFMTOPT
PRINT
  OPUTFMT AS NAME
  OPUTCD AS VALUE
WHERE RPTCD EQ '&RPTCD';
ON TABLE PCHOLD FORMAT XML
ON TABLE SET EMPTYREPORT ON
END


TABLEF preserves the order of appearance in the data table.

OPUTFMT could be defined, as a decode of OPUTCD (or vice versa).
February 21, 2017, 04:08 PM
Michele Brooks
Thank you both for the examples. I will look into both options to see what is the best option to incorporate. Thanks again.


WF 8205, Windows 10
Oracle DBMS
EXL07/PDF Output
February 21, 2017, 04:15 PM
MartinY
Our pleasure to help.

Edit your first post and add [SOLVED] at the beginning of the thread's subject.


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
February 22, 2017, 06:40 PM
Kathleen Butler
Hi Michele,

Did the suggestions resolve your issue?

Thank you everyone!


Sincerely,

Kathleen Butler
Information Builders
February 23, 2017, 01:10 PM
Michele Brooks
Yes. Thanks everyone.

This message has been edited. Last edited by: Michele Brooks,


WF 8205, Windows 10
Oracle DBMS
EXL07/PDF Output