Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Enable / Disable Column in IG based Comparing Sysdate vs Created_Date

Dj SteeleDec 6 2019 — edited Dec 6 2019

Good Afternoon Community,

Our Team and I are using APEX 19.2.0.00.18, Google Chrome, and Oracle 12c Database

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

What I'm Looking to Accomplish:

Disable / Enable a Column in IG based on 2 Conditions (Column POSTED_DATE)

1.) comparing the Created_Date of a Transaction Log (When the Log was Created and Sysdate

2.) whether a Detail Record Exists ; meaning has the end-user created the Transaction "Finish Transaction"

for 1.) This is what I'm Mostly Having an Issue With

I'm Looking to Disable the Column when there is No Detail Record ; meaning the Transactoin has not been completed

or

Disable if the Created Date / Log Date is Equal to Sysdate ; Meaning the user can not select a Posted Date because the Transaction will not Post on same day it would Post a least a Day Later or 2-3 Days Later

Enable Column When P234_DOES_DTL_RECORD_EXIST) = 'YES

and

SysDate > Created Date ; that means the User would be able to select and Update the Transaction with a Posted Date ( Posted Date meaning it Posted to Bank Account)

so for 1.) I've Tried a Page Load DA with the Following code in the Server Side Condition of the DA

but the Column is always enabled (NOTE: I change the Created Date in the Database with an Update Statement to Test if it Disables / Enables when I want

One of my Main Questions is am I comparing sysdate vs created_date correctly ?

Declare v_sysdate date;

      v\_createddate  date;

Begin

If :P234_TRANS_HEADER_ID IS NOT NULL

Then

    select   trim(to\_date(to\_char(sysdate,'MM/DD/YYYY'),'MM/DD/YYYY'))

    into     v\_sysdate

    from dual;

    select trim(to\_date(to\_char(created\_date,'MM/DD/YYYY'),'MM/DD/YYYY'))

    into v\_createddate

    from budget\_trans\_summary\_hdr

    where trans\_header\_id = :P234\_TRANS\_HEADER\_ID;

    if (v\_sysdate = v\_createddate   or   :P234\_DOES\_DTL\_RECORD\_EXIST = 'NO' )

        then 

            return true;  --- Disable (Column Posted Date)

    elsif (v\_sysdate > v\_createddate   and   :P234\_DOES\_DTL\_RECORD\_EXIST = 'YES')

       then

           return true;  -- Enable  (Column Posted Date )

    end if;

End If;

End;

for 2.) I created a Hidden Page Item ( P234_DOES_DTL_RECORD_EXIST) which will have a Value 'YES' or 'NO'

This Hidden Page Item is based on a Page Load DA

with this SQL code to return 'YES' or 'No'

Declare

   v\_count          number(5);

Begin

select count(*) --bt.trans_header_id, bt.allotmentdetailid

into v_count

from budget_detail bt

where bt.trans_header_id = :P234_TRANS_HEADER_ID;

if v\_count = 0 

    then :P234\_DOES\_DTL\_RECORD\_EXIST := 'NO';

elsif v\_count > 0 

    then :P234\_DOES\_DTL\_RECORD\_EXIST := 'YES';

end if;

End;

This Works .... but I Can Not get it to work with the Server Side Condition to also Compare Created Date vs Sysdate as in the PL/SQL Function Body Code above

Also Notice it is ON CHANGE Even --- I would think ON PAGE LOAD Event but that Does Not Work.

pastedImage_91.png

That is Created Date Page Item Labeled as Trans Log Date... so Looking to compare that Date with Sysdate as in the PL/SQL Function Body Code above

pastedImage_118.png

With the DA On Change Event this Works again the "Works" Posted Date is Disabled
but Again I'd Like to Disable / Enable based on the Created Date vs Sysdate in addition to P234_DTL_RECORD_EXIST 'YES' or 'NO'

I'm process of replicating on apex.oracle.com but wanted to at least get the Question / Problem out there

Thanks in Advance,

DSteele41

pastedImage_123.png

Comments
Post Details
Added on Dec 6 2019
1 comment
392 views