Page 1 of 1
Secondary "home" form launched by a button
Posted: Mon Jun 08, 2020 9:23 am
by alextouch
Hi,
is there a way to launch a secondary "home" form from a button?
Or better, I want to put in a launch form 2 buttons, say "DEPARTMENT 1", "DEPARTMENT 2", and clicking on each button will launch a new "nuhome2" or "nuhome3" in which I put same buttons (say HR, INVOICES, and so on), each filtered by department name.
Thank you
Alessandro
Re: Secondary "home" form launched by a button
Posted: Mon Jun 08, 2020 12:31 pm
by kev1n
Hi Alessandro,
You could try this:
Launch Form: Add an onclick handler to each button to set the department.
button_onclick_custom_code.png
Lauch Screen nuhome2: Add some custom code to retrieve set the department name as Hash Cookie
Code: Select all
if (nuFormType() == 'edit') {
nuSetProperty("DEPARTMENT", window.department);
}
Buttons on nuhome2:
Add a Filter #DEPARTMENT#
Re: Secondary "home" form launched by a button
Posted: Tue Jun 09, 2020 10:46 am
by alextouch
Kevin,
I tried to do as you say, but when I open form from a button in nuHome2 filtered by #DEPARTMENT#, it displays nothing.
If I do a nuDebug(nuHash()) in BB of the form, there is [filter] => #DEPARTMENT#, that isn't the value of the hash variable but the variable itself.
Maybe there is something wrong I did.
Re: Secondary "home" form launched by a button
Posted: Tue Jun 09, 2020 7:50 pm
by kev1n
Alessandro,
You must be doing something different. This is my understanding:
Launch Screen (Launch 0) :
Button "Launch Form1" (with onclick event, containing a JS that sets window.department)
Button opens "Launch 1"
Launch Screen (Launch 1) :
Custom Code in Launch Form
Button "Button00" (with Filter #DEPARTMENT#)
Button opens A Browse Screen
run_filter.png
Browse Screen
Add nuDebug(nuHash()) to view the filter
Re: Secondary "home" form launched by a button
Posted: Wed Jun 10, 2020 9:11 am
by alextouch
Kevin,
I did EXACTLY what you wrote and I see that if I do: launch0->button0->launch1->button1->browse form, the browse is empty and the nuDebug(nuHash()) shows this:
nudebug.png
But if I go a step back in the breadcrumb and then return to browse screen, filter appears to be correct like you can see here:
nudebug2.png
Re: Secondary "home" form launched by a button
Posted: Wed Jun 10, 2020 9:21 am
by kev1n
Add some code to debug. The first thing to check is to see if window.department contains the department string:
if (nuFormType() == 'edit') {
nuSetProperty("DEPARTMENT", window.department);
alert('Launch 1, window.department: ' + window.department);
}
Re: Secondary "home" form launched by a button
Posted: Wed Jun 10, 2020 11:28 am
by alextouch
Kevin,
I tried to do as you say:
alert('Launch 1, window.department: ' + window.department); IT'S OKAY, it displays the right string.
This is the RUN tab of button from launch1:
object_run.png
and this is the result from console log after click on button:
console_log.png
If i click on previous breadcrumb entry and then re-click button:
console_log2.png
Re: Secondary "home" form launched by a button
Posted: Wed Jun 10, 2020 12:58 pm
by kev1n
New attempt: Change the JavaScript code as follows:
-> Replace the Button IDs (Button01, Button02 etc.)
Code: Select all
function replaceBtnHashCookie(id, hCookie, value) {
var c = $('#' + id).attr('onclick');
$('#' + id).attr('onclick', c.replace(hCookie, value));
}
if (nuFormType() == 'edit') {
var hCookie = "DEPARTMENT"
nuSetProperty(hCookie, window.department);
replaceBtnHashCookie('Button01', '#' + hCookie + '#', window.department);
replaceBtnHashCookie('Button02', '#' + hCookie + '#', window.department);
}
Re: Secondary "home" form launched by a button
Posted: Wed Jun 10, 2020 4:02 pm
by alextouch
PERFECTLY WORKING!
Nice one!
Thank you Kevin!
Alessandro
Re: Secondary "home" form launched by a button
Posted: Wed Jun 10, 2020 4:50 pm
by kev1n
Cool
