Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

Default value SQL in Text object works only on some forms

Post Reply
crush
Posts: 14
Joined: Tue Apr 02, 2013 8:49 pm

Default value SQL in Text object works only on some forms

Unread post by crush »

Hi,

On simple forms--forms without lookups or subforms, I have Text objects with the Default value SQL field filled. The default value shows up fine. On more complicated forms, the very same fields' default values won't show up.

I'm sorry this is so vague, but I don't know what information might be helpful.

Any idea what could be causing this?

Thank you,
Cassidy
massiws
Posts: 503
Joined: Thu May 24, 2012 2:08 am
Location: Milan, Italy
Contact:

Re: Default value SQL in Text object works only on some form

Unread post by massiws »

Cassidy,
crush wrote:... but I don't know what information might be helpful.
maybe, table schema and/or the SQL code (right and wrong) might be helpful.
crush
Posts: 14
Joined: Tue Apr 02, 2013 8:49 pm

Re: Default value SQL in Text object works only on some form

Unread post by crush »

And the plot thickens...

It isn't the form that dictates if the value will show up. Turns out, if shows up on new entries, but not entries that already exist. Doesn't matter what the SQL is. I used

Code: Select all

SELECT 'foo'[/SQL] in a Text object, FYI.

Any ideas why this is? Or how to get around it?
massiws
Posts: 503
Joined: Thu May 24, 2012 2:08 am
Location: Milan, Italy
Contact:

Re: Default value SQL in Text object works only on some form

Unread post by massiws »

Cassidy,
on text objects Defult Value SQL is executed only when a new record is created.
If you open an existing record this SQL isn't executed, also if the field is empty.

If you want to fill a empty text field on existing records you could use javascript/jQuery in Custom Code > Javascript nuLoadThis() function.
Another way, insert SQL in Text object > All tab > SQL Run Before Display

Hope this make sense.
crush
Posts: 14
Joined: Tue Apr 02, 2013 8:49 pm

Re: Default value SQL in Text object works only on some form

Unread post by crush »

Thank you Max for that clarification.

Let's develop the SQL Run Before Display method. So say I want 'foo' to display in a text field every time the form is loaded. Just putting

Code: Select all

SELECT 'foo'
into SQL Run Before Display doesn't do the trick. I know this is easy to do with nuLoadThis(), but I want to know how to do it with SQL Run Before Display to do more advance stuff.

What would I have to do?
massiws
Posts: 503
Joined: Thu May 24, 2012 2:08 am
Location: Milan, Italy
Contact:

Re: Default value SQL in Text object works only on some form

Unread post by massiws »

Cassidy,
I have explained myself badly: in SQL Run Before Display field you can specify SQL statement(s) that are run before object is created.
You can create a temp file, update other tables, use hash variables, or whatever you want, but the result is not displayed on the object.

For some usage examples execute this SQL on samplenufinancial database:

Code: Select all

SELECT * FROM `zzsys_object` WHERE `sob_all_sql_run_before_display` <> ''
I hope I have been more clear.
Max
Post Reply