Conditional "Redirect to" from a Browse form

Questions related to using nuBuilder Forte.

Conditional "Redirect to" from a Browse form

Unread postby absalom » Sun Apr 18, 2021 10:38 pm

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?
absalom
 
Posts: 25
Joined: Sat Apr 03, 2021 11:20 pm
nuBuilder Version: 4.5

Re: Conditional "Redirect to" from a Browse form

Unread postby kev1n » Sun Apr 18, 2021 11:42 pm

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;
}
kev1n
nuBuilder Team
 
Posts: 1704
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Re: Conditional "Redirect to" from a Browse form

Unread postby absalom » Mon Apr 19, 2021 1:26 am

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 11:20 pm
nuBuilder Version: 4.5

Re: Conditional "Redirect to" from a Browse form

Unread postby absalom » Mon Apr 19, 2021 1:36 am

Sorry for the previous question; it actually works.
absalom
 
Posts: 25
Joined: Sat Apr 03, 2021 11:20 pm
nuBuilder Version: 4.5


Return to General

Who is online

Users browsing this forum: No registered users and 20 guests