We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

validation and cursor navigate?

julia2004
julia2004 asked
on
Medium Priority
1,652 Views
Last Modified: 2007-12-19
hi

i need to validate all items on my form .... if there is any error on a specific item

 the cursor(mouse or key) will go to it and let user 2 correct it..........is that possible?

i don't  want to use post_text_item trigger

thanks
Comment
Watch Question

Commented:
You can use VALIDATE built-in.

Commented:
Hi,

to validate the all fields in a form you can use VALIDATE(FORM_SCOPE) built-in.

Your fields should have when-validate-item triggers and in it you should use RAISE FORM_TRIGGER_FAILURE statement to fail validation. VALIDATE(FOTM_SCOPA) built-in executes all when-validate-item-triggers (also checks validation properties of items). If a validation fails, cursor is placed on the item automatically.

regards

Author

Commented:

thansk

i did it befor ... i use the validation builtin and and set the scope to form

and i put (post_text_item) triggers to all fields i need to check it..

it is not working

i change the items validation triggers to (when validate item) ...also it is the same result

it  skip the validation and do commit!!




 

Commented:
It is recommended that you validate in WHEN-VALIDATE-ITEM trigger.

Check if validation is turned off....If so forms will not do validation.

This has to be done programatically using SET_FORM_PROPERTY built-in:

The following will turn off validation:

SET_FORM_PROPERTY('form_name', VALIDATION, PROPERTY_FALSE);

To find whether it is turned off use:

SET_FORM_PROPERTY('form_name', VALIDATION);

Author

Commented:

it is the same problem :(

get_form_property('myform',valdiation) = true

i think the problem is on the place of calling validate ?

what is your recommendation?


thanks again

Commented:
Hi,

set "Validation Unit" property of your form to "DEFAULT", create a when-validate-item trigger for one of your items and use RAISE FORM_TRIGGER_FAILURE statement to fail validation. Add some messages in your trigger code in order to understand whether or not it is fired.

copy and paste your trigger code please.

regards.

Author

Commented:

i put save button on my form fire this trigger when-button-pressed
(       Validate(form_scope);
IF NOT Form_Success THEN
          RAISE Form_Trigger_Failure;
         END IF;  
  IF :System.Form_Status = 'CHANGED' THEN
 
           Commit_Form;    
     IF :System.Form_Status <> 'QUERY' THEN  
         Bell;       RAISE Form_Trigger_Failure;  
   END IF;
     END IF; )

on  item3 (it is a summation of item1 and item2 )
 i put the trigger when_validate_item
( IF  :Block1.Item3 <> (:Block1.Item1 +:Block1.Item2) THEN
    Message(' Please Check  The Summation ');
    RAISE Form_Trigger_Failure;
      END IF; )




Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:

thanks for your help

it is still not working


your solution check only the result ... item1 and item2 not effected
it will be pass them without checking...

for example
at runtime
i put  item1 = 1 and item2 = 2 and  left  item3 = null
it will be accept it and also
if i put
     item1 = null  and item2 = 2 and    item3 = 3

--
it is useless way to check all item one by one ( i have more than 50 different item on my form need to recalculate ).

i think my problem is clear now

Commented:
Hi,

how do you populate your items? If your item is changed above code will fire validation triggers. If your items are not changed, validate built-in will not fire them. That's why I assigned BLOCK1.Item3 to itself.

Is it acceptable to put all validation triggers into your button code?

Author

Commented:

yes.. it will fire validation trigger only at item3....
if i leave it with out change and change item2 or item1 ... it will be accept it

i don't want to validate all items


----
 it is database items

Commented:
If your item is changed, you need nothing to validate it. When-validate-item trigger is automatically fired when the cursor leaves the item.

Could you copy-paste one of your when-validate-item trigger please?

Author

Commented:

i wrote it befor

on  item3 (it is a summation of item1 and item2 )
 i put the trigger when_validate_item
( IF  :Block1.Item3 <> (:Block1.Item1 +:Block1.Item2) THEN
    Message(' Please Check  The Summation ');
    RAISE Form_Trigger_Failure;
      END IF; )

Commented:
Hi,

write below code in when-button-pressed-trigger. (Change BLOCK2 with your block name) Your button must be in a different block. (If it's in the same block we should make some changes in this code)

DECLARE

  vItem VARCHAR2(100);
  vFirstItem VARCHAR2(100);
  vLastItem VARCHAR2(100);
  vMyBlock VARCHAr2(30) := 'BLOCK2';

BEGIN
      
      vFirstItem := Get_Block_Property(vMyBlock, FIRST_ITEM);
      vLastItem := Get_Block_Property(vMyBlock, LAST_ITEM);
      vItem := vFirstItem;
      
  LOOP
 
    Copy(name_in(vItem), vItem);
    EXIT WHEN vLastItem = vItem;      
    vItem := Get_Item_Property(vItem, NEXTITEM);
 
  END LOOP;

  validate(form_scope);  

END;

Author

Commented:

hi musdu

i solve it .... the problem was in null values

i used NVL function ...and it is working


 IF  NVL(:Block1.Item3,0) <> (NVL(:Block1.Item1,0) +NVL(:Block1.Item2,0)) THEN
    Message(' Please Check  The Summation ');
    RAISE Form_Trigger_Failure;
      END IF; )

thanks alottt for your help
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.