Filter/Restrict Lookup Results?

Questions related to using nuBuilder Forte.

Filter/Restrict Lookup Results?

Unread postby pmjd » Sun Jul 18, 2021 5:53 am

Hello,

Is there a way to restrict which records a Lookup field returns?

So if I have a table with a field that indicates if each record is either "Active" or "Obsolete".

How can I restrict a lookup field in a form to only show the records from the table which are marked as "Active" to be shown for selection?

Thanks,
Paul
pmjd
 
Posts: 76
Joined: Fri Mar 12, 2021 7:08 pm
nuBuilder Version: 4.5

Re: Filter/Restrict Lookup Results?

Unread postby kev1n » Sun Jul 18, 2021 2:13 pm

Hi,

Use nuSetProperty().

See an example here
kev1n
nuBuilder Team
 
Posts: 2012
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Re: Filter/Restrict Lookup Results?

Unread postby pmjd » Sun Jul 18, 2021 5:56 pm

Thanks kev1n, tried that by putting
Code: Select all
nuSetProperty ('iri_status', 'Active');
in the js section of the lookup but it didn't seem to work as the lookup showed all the results. Not sure if it's the wrong place for it but wasn't sure where else it would go.

However, tried another approach of cloning the form that had the info I needed in it and adding
Code: Select all
SELECT * FROM ink_reference_information where iri_status = "Active"
to the SQL of the cloned form in the Browse section of the form's properties. This seems to be working as it gave me th filtered results I was looking for.

Thanks for your help :)
pmjd
 
Posts: 76
Joined: Fri Mar 12, 2021 7:08 pm
nuBuilder Version: 4.5

Re: Filter/Restrict Lookup Results?

Unread postby kev1n » Sun Jul 18, 2021 6:02 pm

Set the Hash Cookie in the onfocus event:

Code: Select all
nuSetProperty ('iri_status', 'Active');


Then in the Lookup form:

Code: Select all
SELECT * FROM ink_reference_information where iri_status = "#iri_status#"
kev1n
nuBuilder Team
 
Posts: 2012
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Re: Filter/Restrict Lookup Results?

Unread postby pmjd » Mon Jul 19, 2021 7:38 am

Tried that but doesn't work for me either. Don't worry about it, happy enough with the other method I found fo using the cloned form (got the idea from one of your previous suggestions on cloning and editing the user management forms for other users) as it allows me to filter the info out that I don#t need.

What I did was:
Set the onfocus event in the lookup object Custom Code, then added the SELECT statement to the SQL in the Lookup tab of the lookup object. on using the lookup on the form it's part of it still displays all records. The form I'm using to look up the records is the same one used for data entry, so creating the clone of it and using a select statement to limit the info displayed seems to work fine.
pmjd
 
Posts: 76
Joined: Fri Mar 12, 2021 7:08 pm
nuBuilder Version: 4.5

Re: Filter/Restrict Lookup Results?

Unread postby kev1n » Mon Jul 19, 2021 8:30 pm

I created a small example "Popup Filter"
Maybe you'll discover what I did differently from you.
kev1n
nuBuilder Team
 
Posts: 2012
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Re: Filter/Restrict Lookup Results?

Unread postby pmjd » Tue Jul 20, 2021 9:09 am

Cool, now see what you meant.

You have: end user can select filter option, then search via lookup. I needed a non-end user selectable pre-filter (using the restricted form) so that no choice of what can be filtered is possible.

Sorry if I didn't explain the requirements properly but interseting to see that option available too
pmjd
 
Posts: 76
Joined: Fri Mar 12, 2021 7:08 pm
nuBuilder Version: 4.5


Return to General

Who is online

Users browsing this forum: No registered users and 15 guests