Why don't run the macro sc_lookup in onapplicationoninit

Hello, i have a macro sc_lookup in the onapplicationoninit that execute a select statement, i need get a value from database and put readonly if a rule is truly with the macro sc_apl_conf .

But i get a error message from scriptcase: UNDEFINIED PROPERTY form_enc_ini::$Db

I don’t undestand why i can not execut a select statement in that event.
How can i do it?

Re: Why don’t run the macro sc_lookup in onapplicationoninit

on this event the database is not open yet.

See the dosc -> ScriptCase macros -> Macros x Application

And onapplicationoninit only execute one time, problably you’ll have problem when navigating(the event wont execute again).

The event that you need is onLoad (is when scriptcases get the row at the database).
And use sc_field_readonly to turn on the field readonly dynamically.

Please, see more how to use the macros at the documentation.

Re: Why don’t run the macro sc_lookup in onapplicationoninit

Hello Diogo,

Thanks you, it works perfect!!.

I will read about how work each event into a form.

Re: Why don’t run the macro sc_lookup in onapplicationoninit

When i use sc_field_display for some fields in onload event, but those are requerides, and i try save, scriptcase show a message for field requerides.

How i can quit that property REQUERIDE to those fields?