Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Secondary "home" form launched by a button

Questions related to using nuBuilder Forte.
Post Reply
alextouch
Posts: 38
Joined: Tue Jun 05, 2012 2:40 pm
Location: Bologna, Italy
Contact:

Secondary "home" form launched by a button

Unread post 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
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 448 times
Contact:

Re: Secondary "home" form launched by a button

Unread post 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#
You do not have the required permissions to view the files attached to this post.
alextouch
Posts: 38
Joined: Tue Jun 05, 2012 2:40 pm
Location: Bologna, Italy
Contact:

Re: Secondary "home" form launched by a button

Unread post 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.
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 448 times
Contact:

Re: Secondary "home" form launched by a button

Unread post 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
You do not have the required permissions to view the files attached to this post.
alextouch
Posts: 38
Joined: Tue Jun 05, 2012 2:40 pm
Location: Bologna, Italy
Contact:

Re: Secondary "home" form launched by a button

Unread post 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
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 448 times
Contact:

Re: Secondary "home" form launched by a button

Unread post 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);
}
alextouch
Posts: 38
Joined: Tue Jun 05, 2012 2:40 pm
Location: Bologna, Italy
Contact:

Re: Secondary "home" form launched by a button

Unread post 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
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 448 times
Contact:

Re: Secondary "home" form launched by a button

Unread post 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);

}
alextouch
Posts: 38
Joined: Tue Jun 05, 2012 2:40 pm
Location: Bologna, Italy
Contact:

Re: Secondary "home" form launched by a button

Unread post by alextouch »

PERFECTLY WORKING!
Nice one!

Thank you Kevin!

Alessandro
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 448 times
Contact:

Re: Secondary "home" form launched by a button

Unread post by kev1n »

Cool :D
Post Reply