Welcome to the nuBuilder Forums!

Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.

Go back to nuuserhome after saving

Questions related to using nuBuilder Forte.
Locked
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Go back to nuuserhome after saving

Unread post by toms »

Hi,

After a save action is triggered, I'd like to redirect the user back to nuuserhome.

The workflow would go like this:

1. The user clicks a button on nuuserhome
2. A new record is opened (Edit Form)
3. The record is saved by the user
4. --> The user is directed back to nuuserhome

I wrote a function that takes the user back to nuuserhome. Where would be the best place to call this function?

Code: Select all

function goBackToUserHome() {
if (nuFORM.getCurrent().form_code == 'nuuserhome') {return;}
var b = window.nuFORM.breadcrumbs.length;
for (var i = 0 ; i < b ; i++){
   if (window.nuFORM.breadcrumbs[i].form_code == 'nuuserhome') {
      nuGetBreadcrumb(i);
      return;
   }
 }
}
admin
Site Admin
Posts: 2829
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 30 times

Re: Go back to nuuserhome after saving

Unread post by admin »

toms,

You could use nuGetBreadcrumb(0).

http://wiki.nubuilder.net/nubuilderfort ... Breadcrumb

Steven
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: Go back to nuuserhome after saving

Unread post by toms »

Steven,
admin wrote:You could use nuGetBreadcrumb(0).
While this would work in most cases, breadcrumb 0 is not necessarily always nuuserhome. E.g. when you login automatically passing f/r parameters or while you are logged in as 'globeadmin'
That's why I wrote this goBackToUserHome() function.

Code: Select all

Where would be the best place to call this function? 
My question was, where to call this function from? After a user has hit "save" I need to know when the saving action is done so I can call goBackToUserHome().
admin
Site Admin
Posts: 2829
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 30 times

Re: Go back to nuuserhome after saving

Unread post by admin »

toms,

OK, Good question.

You need to call your Javascript in the Javascript section of the Form.

But in the flowchart below, squares 1, 2 and 3 is Javascript from the same Form.
flow3.png
So you'll need to use if statements to know where it is running.

Code: Select all

if(nuFormType() == 'browse'){
   //-- Box 1
}else{

   if(nuIsSaved()){
      //-- Box 3
   }else{
      //-- Box 2
   }

}
I have just added nuIsSaved()... http://wiki.nubuilder.net/nubuilderfort ... #nuIsSaved

So, to go back to another Breadcrumb after you have Saved a record, you'll need to check you are in Box 3.


Steven
You do not have the required permissions to view the files attached to this post.
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: Go back to nuuserhome after saving

Unread post by toms »

Perfect, it works as expected!
admin
Site Admin
Posts: 2829
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 30 times

Re: Go back to nuuserhome after saving

Unread post by admin »

.
Locked