Welcome to the nuBuilder Forums!

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

Conditional "Redirect to" from a Browse form

Questions related to using nuBuilder Forte.
Post Reply
absalom
Posts: 25
Joined: Sat Apr 03, 2021 3:50 pm

Conditional "Redirect to" from a Browse form

Unread post by absalom »

Hi, I have a Browse form for a view in my database. This view is made from a UNION request, and primary key is not relevant here. Since a primary key is mandatory in the nuBuilder form, I decided to include a field called "fake_id" in my view. The "fake_id" field contains either NULL (first part of the UNION) or an actual ID (from the second part of the UNION).
Since I have a fake "primary key" for my nuBuilder form, I decided to take some benefit from it and also use the "redirect to" ability. But what I would like is:

* inactive click when the user selects something with NULL in the "fake_id" field;
* actual redirect when the user selects something with an id.

The current behaviour is always redirecting (relevant redirecting when there is an id and redirecting to a dummy new record when the id is NULL).

How could I disable the useless redirecting in order to prevent the users inserting dummy things if they mistakenly click on some records from my Browse form?
kev1n
nuBuilder Team
Posts: 4305
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Conditional "Redirect to" from a Browse form

Unread post by kev1n »

Instead of settings"Redirect to" in the Form Properties dialog, add a nuSelectBrowse() function in your form's Custom Code:

Code: Select all

function nuSelectBrowse(e) {

    var r = $(e.target).attr('data-nu-primary-key');
    if (r !== null) {
         nuForm('replace_with_the_redirect_to_form_id', r, '', '', '0');
    }

    return false;
}
absalom
Posts: 25
Joined: Sat Apr 03, 2021 3:50 pm

Re: Conditional "Redirect to" from a Browse form

Unread post by absalom »

I see, thank you.

How can I enable it for all users; I currently get an error message saying: "Access To Form Denied... ()"
absalom
Posts: 25
Joined: Sat Apr 03, 2021 3:50 pm

Re: Conditional "Redirect to" from a Browse form

Unread post by absalom »

Sorry for the previous question; it actually works.
Post Reply