Page 1 of 2

Search Objects for New Records

Posted: Thu Jun 13, 2024 10:41 am
by ajackson
Greetings,

I have a browse form which takes me to its associated edit form for a new record when I press the Add button.
On the edit form I have several select objects both of type 'Select' and 'Input: Select'.
All of these are based on select statements that work when existing records are edited but produce no results for new records and hence empty select lists.

How is this so? Am I missing something?

Cheers,
Alan

Re: Search Objects for New Records

Posted: Thu Jun 13, 2024 10:46 am
by kev1n
Hi,

Do you use Hash Cookies in the SQL / can you post an example of an SQL here?

Re: Search Objects for New Records

Posted: Thu Jun 13, 2024 11:32 am
by ajackson
Here's the SQL:

select distinct timepoint
from StudyTimepoint
where timepoint is not null
order by timepoint

No hash cookies in sight!

Re: Search Objects for New Records

Posted: Thu Jun 13, 2024 11:35 am
by ajackson
Are you able to replicate the problem?

Re: Search Objects for New Records

Posted: Thu Jun 13, 2024 11:47 am
by kev1n
The SQL must return 2 column, not 1 (See wiki)

If the display and the bound value are identical, use

Code: Select all

select distinct timepoint, timepoint
from StudyTimepoint
where timepoint is not null
order by timepoint

Re: Search Objects for New Records

Posted: Thu Jun 13, 2024 12:09 pm
by ajackson
Unfortunately this doesn't work either.
It must be something else as it works when editing records.
I've even stripped down the SQL statement to:

select 'test' as study, 'test' as study

Re: Search Objects for New Records

Posted: Thu Jun 13, 2024 12:57 pm
by kev1n
I can't replicate the issue on my end. However, it's possible that the problem stems from another issue within the form.
Please check nuDebug Results, the server log, and the developer console for any errors.

Does the issue also occur if you create a completely new form with only one single select object on it?

Re: Search Objects for New Records

Posted: Thu Jun 13, 2024 1:05 pm
by ajackson
I'll investigate and get back to you...

Re: Search Objects for New Records

Posted: Thu Jun 13, 2024 2:26 pm
by ajackson
Hi Kevin,

Looking in the debug results it turns out that another sql statement in another tab had errors due to an undefined hash variable when a new record is displayed. So I've made sure that all hash variables have default values so that no errors are produced and now the list boxes are correctly populated.

In doing this however I'm finding that I'm unable to set the default value of a lookup object. I've tried the methods outlined here:
https://github.com/nuBuilder/nuBuilder- ... ault_value
but to no avail. Can default values for lookup objects be set?

Thanks for pointing me in the right direction!

Cheers,
Alan

Re: Search Objects for New Records

Posted: Thu Jun 13, 2024 2:45 pm
by kev1n