Focal Point
[SOVLED] Default dynamic parameter in html page

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

October 23, 2014, 08:09 AM
Mikey
[SOVLED] Default dynamic parameter in html page
How can I default a dynamic dropdown parameter in an htm file based on the &FOCSECUSER? I have a fex that retrieves the States from a table and that is how I get the States drop down parameter in the html page. Right now I have the Add "ALL" option checked off so that is always the first option. I need to be able to default to say for example: "FL" if &FOCSECUSER is "Gary".

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


8007
Windows 7, PDF, Excel
October 23, 2014, 08:42 AM
MartinY
Haven't been tested, but something like this.
In a fex, assign a variable to the State you want for the user.
Below SET is not the better way to do it, but if you can have it from a TABLE FILE, it will be better:
-SET &#DFLSEL = DECODE &FOCSECUSER ('Gary' 'FL' 'Ted' 'NY' ELSE '_FOC_NULL');


In your HTML (where DropList is the unique identifier of your control):
function onInitialUpdate()
{
	dflSel = '!IBI.AMP.#DFLSEL;';
	IbComposer_setCurrentSelection('DropList', dflSel, false);
}



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
October 23, 2014, 03:27 PM
Mikey
im not 100% sure if this is the solution Im loking for. What I have now is a parameter for States that is a drop down. I also created a fex that just returns the current user and added that as a hidden parameter. is there a javascript way to say: if user parameter = Gary then State default FL, if user = Jim then State default CA else _FOC_NULL. Also, if Gary runs report and the default is FL, he still needs to be able to see all other states in the drop down so he can change it.


8007
Windows 7, PDF, Excel
October 24, 2014, 07:34 AM
MartinY
Indeed, it's the solution.

From your fex that returns the current user, assign the default State as well as I shown in my previous post (the DECODE statement).
If the default State can be retrieve from a TABLE it's even better.
Doing it from the fex it's easier than doing it in JS.

Then the code in onInitialUpdate() function only assign a the selected value for the dropdown.
Your dropdown for States must still be filled with your fex that list every States.
onInitialUpdate() is ran after all the default are loaded.


Otherwise in JS it may look something like this
function inInitialUpdate()
{
	logUsr = IbComposer_getCurrentSelection('HiddenParmLogUser');


	if (logUsr == 'Gary')
		IbComposer_setCurrentSelection('StateDropList', 'FL', false);
	else if (logUsrl == 'Jim')
		IbComposer_setCurrentSelection('StateDropList', 'CA', false);
	else
		IbComposer_setCurrentSelection('StateDropList', '_FOC_NULL', false);
}


But having hard coded user's name it's really not the good thing to do.

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
October 24, 2014, 09:01 AM
BarryS
Hi Mikey

You can get the userid and put in a default and return it to a hidden control and in onInitialUpdate function you can IbComposer_setCurrentSelection( controlName, IbComposer_getCurrentSelection( hiddenControlNamed), false); if you have any issues open a case and ask for Barry.

Thanks Barry


WebFOCUS 8103, Windows, App Studio
October 24, 2014, 11:27 AM
Mikey
MartinY,
This is my first attempt at JavaScript and your second post helped it make more sense and this works, thanks!

function onInitialUpdate()
{
dflSel = IbComposer_getCurrentSelection('USER_STATE');
IbComposer_setCurrentSelection('STATE', dflSel, false);
}

BarryS, this looks similar to what you recommended too.

Thanks!


8007
Windows 7, PDF, Excel
October 24, 2014, 11:38 AM
MartinY
My pleasure.

Edit the first post of this thread and add [SOVLED] at the beginning of the 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
October 24, 2014, 01:38 PM
Mikey
Will do. And wanted to mention, there is a "Save Selections Button" I just found out about from a co-worker. Apparently we are going to use that now.


8007
Windows 7, PDF, Excel
October 24, 2014, 02:17 PM
MartinY
You know that the "SaveSelection" button will only save the selections made by the user from your HTML page ? It is saved into a file which can be then re-opened and have the HTML already filled up with saved values.
Each saved file will be located under user's personal folder.


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
October 27, 2014, 07:42 AM
Mikey
Yes, Ive emailed this javascript option too and let the business decide. Thanks again!


8007
Windows 7, PDF, Excel