Link to home
Start Free TrialLog in
Avatar of julia2004
julia2004

asked on

validation and cursor navigate?

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
Avatar of mudumbe
mudumbe

You can use VALIDATE built-in.
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
Avatar of julia2004

ASKER


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!!




 
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);

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
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.

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; )




ASKER CERTIFIED SOLUTION
Avatar of musdu
musdu

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

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
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?

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
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?

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; )

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;


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