I have a dynamic action which I want to do a number of checks in a javascript condition before it fires. I want it to only show a region, if a date coming back from the database into a read only field (P4_NEXT_RENEWAL_DATE) is LATER than todays system date.
My oracle table has a date field, being returned into a read only page item:
P4_NEXT_RENEWAL_DATE
This returns a value such as:
Next Renewal Date
16-JUL-2017
I have a dynamic action, which looks as below:
(
(apex.item('P4_RENEWAL_REQUIRED').getValue()=='Yes' && apex.item('P4_RENEWAL_REQUIRED_AGREE').getValue()=='Agree')
||
(apex.item('P4_RENEWAL_REQUIRED').getValue()=='No' && apex.item('P4_RENEWAL_REQUIRED_AGREE').getValue()=='Disagree')
)
&&
Date.parse(apex.item('P4_NEXT_RENEWAL_DATE').getValue()) > new Date()
it is this last bit which is not working,
&& Date.parse(apex.item('P4_NEXT_RENEWAL_DATE').getValue()) > new Date()
which I was hoping would only show the region if my next renewal date was later than todays date....but it shows the region regardless of if the date is in the past or the future.
I am not sure if my read only field is returning a string version of the date in P4_NEXT_RENEWAL_DATE, or if Apex knows its a date value coming from Oracle, and so javascript treats it as a date value...I have tried a few date.parse() methods but nothing seems to work.
I also tried not using date.parse, and using a straight apex.item.getValue() call which I would have through returned the raw date object, but no luck either:
&& apex.item('P4_NEXT_RENEWAL_DATE').getValue() > new Date()
Any advice appreciated.