Re: record validation status
Date: 1996/11/19
Message-ID: <56t58r$lch_at_shadow.CSUFresno.EDU>#1/1
In article <3291F0EC.10ED_at_ix.netcom.com>,
Damon Bowman <dbowman2_at_ix.netcom.com> wrote:
>I am using a When-Create-Record trigger to populate some items with
>data-driven default values. How can I prevent Forms 4.5 from attempting
>to validate this record when the user has not entered anything?
>
>In other words, I would like the default values I am populating with
>triggers to behave as if they were being set via the Default Value item
>property. I have tried setting the record status to NEW, but the
>internal validation status is apparently not the same as the status I
>can modify with the Set_Record_Property built-in. I have also tried
>setting the individual items to VALID after populating their values.
>
>Any suggestions? I am considering a key-prevrec trigger that checks
>each field for entered values, then clears the record if no fields have
>been entered. This is not an ideal solution, because it does not handle
>new records that are the only record in the block. It also does not
>handle mouse navigation out of the record.
I used a different trigger: When-Validate-Item at the block level. (Each item-level WVI trigger must have its 'Execution Style' set to After for this to work properly). The block-level WVI trigger runs ONLY after the user enters a value into the created record, otherwise, no default values are set and no validation occurs.
The code in the record-level WVI trigger looks something like this:
IF :SYSTEM.RECORD_STATUS = 'INSERT' THEN If itm1 is null then set_itm1_default; end if; If itm2 is null then set_itm2_default; end if;
If required_itm is null then
:required_itm := null; --Causes required itm's WVI trigger to run
End If; --when user leaves the record.END IF; Record_Status must be checked because using the mouse to click out of the new record causes the WVI triggers to run, unlike using keyboard keys, where the WVI triggers don't run.
The above code prevents the user from forcing a default back to null. If this isn't what you want, then a row-level flag could be set to prevent the above code from running more than once on the record.
I also set the defaults if the user presses the key-crerec (F6) key, since I am assuming they are doing this on purpose. They would have to delete the created record to prevent it from being inserted into the database.
If you don't like the above method, instead of your key-prev-record trigger, you could create an on-insert trigger that checks the record. If the user has entered anything in addition to the defaults, then do an Insert_Record. But if nothing else was entered, then skip the Insert_Record. You would need to re-query the block after the commit in this case, so the non-inserted records would disappear from the form.
Hope this helps.
Regards,
Steve Cosner
Received on Tue Nov 19 1996 - 00:00:00 CET