apodictus wrote:So what is the read-only condition? Why doesn't it check that the end date correctly terminates the subscription?
I'm pulling my hair over validation vs conditional read only behaviour.
I have a detail form on a subscription record.
All fields on the form are "display only" except for the end date of the subscription. The whole purpose a the form is to fill in an end date when the subscription expires. Of course you can end a subscription only once. So after I put in a read only condition on the end date. If a users selects a record that is already ended the form is read-only
All is well until, except when a user make a mistake enters a valid date, which is logically wrong (like a end date before the start date)
An item validation kicks in telling the user the date is wrong. But because of the way apex is working. After this page validation the page is reloaded. Session state now contains the wrong date thus the read only condition is met and validation error is displayed while the date is now read only. Now the users knows he's done something wrong but he can't change it. It's a bit chicken and the egg. If I take out the condition on everything works, but then the form remains updatable. (hence you can alter the end date and save again). After a subscription has ended you should not be allowed to change it again.
I can fix the problem with a solution like changing the read only condition to look at the actual database value instead of the item value. However this will effectively caused the record to be pulled from the database twice. Once by apex for the entire record and then again for the condition.
The problem seems like such basic behaviour. I can't believe there isn't a more easy way like my original approach. Which would have worked like a charm if I did not need validations.
apodictus wrote:It's not simply a case of it having a value or not, it has to be a valid value. The read-only condition should include the required validation:
The page item with the end date (let's say P1_END_DATE) is of display type "DATE PICKER"
The item also has the a readonly condition :P1_END_DATE is not null.
Which renders the datepicker as read only when a the item has got a value and renders it as datepicker when the item does not have a value
or whatever the required validation is.
to_date(:P1_END_DATE) > to_date(:P1_START_DATE)