Tips and wisdom from 15 years of DBA experience

Thursday, October 22, 2009

How to set Oracle Apex Checkbox default value

As often is the case when I blog about something, I spent waaaaay too much time trying to figure out how to do something that is seemingly very simple. In this case my trivial requirement was to create a single checkbox, that when checked, puts "Yes" in the database, and when unchecked, puts "No" in the database. Here is how to do it:

- Create your Checkbox item.
- Make sure that the following are set in the "List of Values" section of the checkbox item:

Named LOV: - Select Named LOV -
Display Extra Values: No
Dynamic Translation: - Not Translated -
Number Of Columns: 1
Display Null: No
Null Display Value:
Null Return Value:
List of values definition: STATIC:;Yes

Save these changes, if you made any and then add a computation to the page as follows:

Click the "Create" icon.
Choose "Item on This Page"
click next...

Compute Item: (The checkbox you want to modify)
Sequence: (choose the default)
Computation Point: After Submit
Computation Type: Static Assignment
click next...

Computation: (Value you want to return) for example: No
click next...

Condition Type: Value of Item in Expression 1 is NULL
Expression 1: (name of checkbox you want to modify. Example: P1_DATA_FG
click create...

Viola! Give it a shot, and it should work for you. I learned all this stuff from here:

http://forums.oracle.com/forums/thread.jspa?messageID=3832343
and
http://asun.ifmo.ru/docs/htmldb_22/appdev.22/b28839/check_box.htm

Craig Glendenning

3 comments:

Skip Straus said...

Glenn,
Excellent clear post. Why isn't this in the APEX 4.1.1 documentation?

Skip

Anonymous said...

After wrestling with a checkbox for a few hours to return a proper value on null, these steps took me less than five minutes and worked perfectly. Thank you

Anonymous said...

Thanks!

Followers