This content has been marked as final. Show 12 replies
On your form you have an item that keeps primary key value.
When you are inserting new record this value is null.
Make your validation conditional - run it only if primary key item is null
Here is what I want:
The field is not mandatory so it's possible user leave it empty when they first create the record(with other fields entered), then later on when they open the form and edit the record, he can enter the Date field and when he does, I want the validation process also triggered.
1. If user create a total new record, if he put a date into the field, it must be today or later; he can leave that field blank at this time though
2. Later When Edit, if the the field is still empty on that record, when user put date there, it must be today or later; If the field is not empty(may contain date earlier than today) and user want to modify it, it must be today or later; but if he doesn't want to modify that field, the value there is ok
So whenever user enter a date or modify a date, I want the new date put there is either today or later.
I'm talking about primary key - it's mandatory!
It could be hidden and probably generated by sequence or trigger but
there should be such field in the form.
Put example on apex.oracle.com - it will be easier to help you
Here is the example: http://apex.oracle.com/pls/apex/f?p=48914
See the receive date col, what I want is that if I create a new record and put the date there, the date can only be today or later--- This can be care of by the Primary Key+Validation you mentioned;
But that doesn't work When I try to Edit the second record, it's receive_date is empty now and when I edit and put a date there, I want the date also to be either today or later.
I also need access to your workspace (workspace, user name, password)
Edited by: mike on Aug 19, 2011 11:23 AM
In your situation it's even easier - you have page 2 that is used for insert and page 3 that is used for update.
Date is validated only on page 2 (when inserted)
But you should also consider your business logic - what if user inserts correct (future) date and immediately after that updates record and enters wrong date.
The validation need to be performed on both insert page(2) and edit page(3); on Edit page, if the existing record(record 2) is having null in the reveive_date, he can put a date there but the date need to be today or later.
I will have another logic in place: if the received_date is not empty, they are not allowed to modify it anymore. So the validate need to take place first time user put a date there, but he can leave it empty when he first create the record.
Look at the page 3.
1. added :P3_RECEIVE_DATE_BEFORE - hidden
2. Computation "before regions" P3_RECEIVE_DATE_BEFORE
It saves initial value of P3_RECEIVE_DATE
begin return :P3_RECEIVE_DATE; end;
3. Validation P3_RECEIVE_DATE
This validation is conditional - it's executed only if P3_RECEIVE_DATE_BEFORE is not null
begin if TO_DATE(:P3_RECEIVE_DATE,'dd-MON-YYYY') < sysdate then return false; else return true; end if; end;
Hope it helps.
Thanks A LOT!
It works, just the way I want it to be.
Have a great weekend!
i've to validate if my :P58_TITDATEECHEANCE higher than :P58_DATEJOUISS in apex 4.2
I've code a Function returning booelan like this. But when i test it and change the dates i always have the same result (my message error)
Anyone have an idea?
IF TO_DATE(:P58_TITDATEECHEANCE,'DD-MM-YYYY') >= TO_DATE(:P58_DATEJOUISS,'DD-MM-YYYY') THEN
i wont to validate an item (p7_id) and i wont that if somebody try to delete the item building to show a message that explain that you have to delete first the houses that belong to this building... haw can i do that?