2 Replies Latest reply: Feb 25, 2014 12:45 PM by NewApexCoder RSS

Apex maintaining a checkbox and setting a column value

NewApexCoder Newbie
Currently Being Moderated

Apex 4.2

I'm having some trouble with checkboxes. I have pseudocoded the process but not sure how to implement uses checkboxes. Here's the full story:

 

I have an interactive report based off Table ORGANIZATIONS on Page 1

 

ORGANIZATIONS

-----------------------

ORG_ID         PK

ORG_NAME

ORG_TYPE

QA_DATE

 

On the data entry page(Page 2), a user can fill in the org name and org type. There is also a checkbox that the user can click / check once they have done their research on the organization and approved it. Checking this checkbox should set the QA_DATE to the SYSDATE.

 

So Page 2 would have the following page items:

P2_ORG_ID

P2_ORG_NAME

P2_ORG_TYPE

P2_CHECKBOX

 

I was thinking that when I submit the page, I could have a pl/sql process that says if the checkbox is checked, update the ORGANIZATIONS table and SET the QA_DATE to the SYSDATE.

I'm just not sure how to:

- Handle checking if the checkbox is checked. 

- What values to even put in the LOV for the checkbox if necessary

- Or how to retain or keep the checkbox checked once you leave the page

 

I had also thought that there would need to be an ON LOAD process on Page 2 that sets the checkbox to 'checked' if the QA_DATE IS NOT NULL. Thats my best solution for retaining the checkbox since its a page item.

 

Any help on this top would be greatly appreciated. THanks in advance for your help.

  • 1. Re: Apex maintaining a checkbox and setting a column value
    Nicolette Expert
    Currently Being Moderated

    NewApexCoder

     

    In your situation the List of values example STATIC:;Y (show just the checkbox and return Y) is the most appropriate.

    This will show the checkbox and when it is checked the value of the item is Y. Unchecked the value will be null.

    Since the checkbox isn't a database column it doesn't really matter what you choose as return value as long as you're consistent. Using Y as the return value used makes sense in this case.

     

    For holding the checkbox checked after submit. Have QA_DATE as a page item too (P2_QA_DATE) with source type database column. Then for P2_CHECKBOX have source type "PL/SQL expression" with source case when QA_DATE is null then null else 'Y' end. This will check if there is a QA_date and uncheck when the column is empty.

    You could use a computation on submit to set P2_QA_DATE when P2_CHECKBOX is Y. And use the wizard generated DML process to do the update.

     

    In general the checkbox item could display multiple checkboxes for example:

    select dep.department_name, dep.department_id
    from   oehr_departments dep

    as lov will show a checkbox for every department with department name as option label.

    All return values of the checked checkboxes form a colon delimeted string.

    Show with the above lov having the following entry

    10    Administration

    20    Marketing

    30    Purchasing

    If you check Administration and Purchasing the item value will be 10:30.

    See this example for some fun with a checkbox.

     

    Nicolette

  • 2. Re: Apex maintaining a checkbox and setting a column value
    NewApexCoder Newbie
    Currently Being Moderated

    Thank you for your input, it has surely helped out. Your information, explanation, and example worked like a charm. Thanks alot!!

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points