Home » Developer & Programmer » Forms » when-validate-item trigger doesn't fire (Oracle Forms 11g)
when-validate-item trigger doesn't fire [message #589639] Tue, 09 July 2013 05:38 Go to next message
metal_navin
Messages: 21
Registered: February 2013
Junior Member
Good day.
I am trying to make a particular field (called reason_code) "required" on a form I am working on.
Now this field has two fields before it, and I have to tab to reach my reason_code field.

But the functionality I want is that when I tab into the reason_code field, the WHEN-VALIDATE-ITEM trigger should fire even when this field is NULL.

IF :REASON_CODE IS NULL THEN
  MESSAGE ("Please enter a reason code!");
end if;


The trigger doesn't fire when I don't enter a reason_code field and I can tab past this field and not get the ("Please enter a reason code!") error message.

On researching the problem, I saw that this field has to be of status "CHANGED" in order for the trigger to fire.
Can you advise how to do this at item level?

Or if not, can you please suggest another solution in making this field required.?

Thanks.
Re: when-validate-item trigger doesn't fire [message #589640 is a reply to message #589639] Tue, 09 July 2013 06:12 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
What's wrong with setting the required property?
Re: when-validate-item trigger doesn't fire [message #589641 is a reply to message #589639] Tue, 09 July 2013 06:12 Go to previous messageGo to next message
Littlefoot
Messages: 21811
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Why don't you, instead of programming, just set that item's "Required" property to "Yes"?
Re: when-validate-item trigger doesn't fire [message #589664 is a reply to message #589641] Tue, 09 July 2013 09:49 Go to previous messageGo to next message
metal_navin
Messages: 21
Registered: February 2013
Junior Member
Littlefoot wrote on Tue, 09 July 2013 06:42
Why don't you, instead of programming, just set that item's "Required" property to "Yes"?


Thanks for the response.
Setting this property doesn't work.
Please note that I am running this form on a application server web front end
Re: when-validate-item trigger doesn't fire [message #589665 is a reply to message #589664] Tue, 09 July 2013 09:57 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
define doesn't work, probably it's just not firing when you expect, same as the trigger - Check your form validation unit property.
Re: when-validate-item trigger doesn't fire [message #589667 is a reply to message #589665] Tue, 09 July 2013 11:18 Go to previous messageGo to next message
metal_navin
Messages: 21
Registered: February 2013
Junior Member
Right now, that property is set to 'ITEM'

should it be set to 'FORM'?
Re: when-validate-item trigger doesn't fire [message #589671 is a reply to message #589667] Tue, 09 July 2013 17:09 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
probably should be item. Is your item a database item?
Re: when-validate-item trigger doesn't fire [message #589672 is a reply to message #589671] Tue, 09 July 2013 19:29 Go to previous messageGo to next message
metal_navin
Messages: 21
Registered: February 2013
Junior Member
No it isn't a database item.

So I assume that since its not a database item, maybe the validation property should be "form"?
Re: when-validate-item trigger doesn't fire [message #589673 is a reply to message #589639] Tue, 09 July 2013 21:14 Go to previous messageGo to next message
reaz62
Messages: 15
Registered: December 2012
Location: dhaka
Junior Member
hi
please update the code as

IF :REASON_CODE IS NULL THEN
MESSAGE ("Please enter a reason code!");
raise form_trigger_failure
else
null;
end if;

/* hope it will work*/
Re: when-validate-item trigger doesn't fire [message #589674 is a reply to message #589673] Tue, 09 July 2013 21:41 Go to previous messageGo to next message
metal_navin
Messages: 21
Registered: February 2013
Junior Member
reaz62 wrote on Tue, 09 July 2013 21:44
hi
please update the code as

IF :REASON_CODE IS NULL THEN
MESSAGE ("Please enter a reason code!");
raise form_trigger_failure
else
null;
end if;

/* hope it will work*/



thanks for the suggestion,
But it didn't work.
argh Smile
Re: when-validate-item trigger doesn't fire [message #589677 is a reply to message #589674] Tue, 09 July 2013 23:56 Go to previous messageGo to next message
Littlefoot
Messages: 21811
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I created a form based on Scoot's DEPT table (DEPTNO being a NOT NULL column). Data Block Wizard already set its "Required" property to "Yes". I ran the form. Pressing <Tab> or <Enter> (i.e. performing "next item" operation), Forms didn't allow that, saying that item's value must be entered.

I believe that it is the functionality you want to use as well.

(I use Forms 10g, but I believe that it behaves the same as your 11g version).

Check form Property Palette - what's "Defer Required Enforcement" set to? Set it to "No" because, if "Yes", "Required" property is not enforced until record is validated.
By the way, my "Validation Unit" property is set to "Default").
Re: when-validate-item trigger doesn't fire [message #589700 is a reply to message #589677] Wed, 10 July 2013 02:34 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
@LF - it's not a database item - different rules apply.

@reaz62 - it's not firing because non-database items start life with a valid property of true and this won't change until a value is entered. Database items in a new record start with a valid property of false.

The check needs to go somewhere else entirely. How are these non-db items being used in the form?
Re: when-validate-item trigger doesn't fire [message #589710 is a reply to message #589700] Wed, 10 July 2013 05:38 Go to previous messageGo to next message
metal_navin
Messages: 21
Registered: February 2013
Junior Member
cookiemonster wrote on Wed, 10 July 2013 03:04
@LF - it's not a database item - different rules apply.

@reaz62 - it's not firing because non-database items start life with a valid property of true and this won't change until a value is entered. Database items in a new record start with a valid property of false.

The check needs to go somewhere else entirely. How are these non-db items being used in the form?


Hey CM,
After the reason code is entered, it is being being inserted into a database table column. Thats about it.

With respect to what you were saying about the valid property, is there a way to somehow change the valid property of the item to false for this item?

Thanks.
Re: when-validate-item trigger doesn't fire [message #589713 is a reply to message #589710] Wed, 10 July 2013 05:43 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
You can always use set_item_instance_property.
However - why is the item not a db item if you're inserting the value into the db?
Re: when-validate-item trigger doesn't fire [message #589721 is a reply to message #589713] Wed, 10 July 2013 06:17 Go to previous messageGo to next message
metal_navin
Messages: 21
Registered: February 2013
Junior Member
cookiemonster wrote on Wed, 10 July 2013 06:13
You can always use set_item_instance_property.
However - why is the item not a db item if you're inserting the value into the db?


Well, this field is basically a text field, where you input data to be inserted into another table, so its not really a db field.

This item has multiple records on the form, and I was reading that using the set_item_property should work for multiple records, instead of the set_item_instance_property. I used the below in the When-validate-item trigger of the REASONCODE item.
   set_item_property('REASON',ITEM_IS_VALID,PROPERTY_FALSE) ;

   IF :REASON IS NULL then 
   Message ("reason code cannot be null!");
   END IF; 


but this didn't work.
Did I put the trigger in the correct place?

Thanks
Re: when-validate-item trigger doesn't fire [message #589730 is a reply to message #589721] Wed, 10 July 2013 06:36 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
metal_navin wrote on Wed, 10 July 2013 12:17

Well, this field is basically a text field, where you input data to be inserted into another table, so its not really a db field.

That doesn't help much in trying to understand your process. Is the item in a database datablock?

metal_navin wrote on Wed, 10 July 2013 12:17

This item has multiple records on the form, and I was reading that using the set_item_property should work for multiple records, instead of the set_item_instance_property. I used the below in the When-validate-item trigger of the REASONCODE item.
   set_item_property('REASON',ITEM_IS_VALID,PROPERTY_FALSE) ;

   IF :REASON IS NULL then 
   Message ("reason code cannot be null!");
   END IF; 


but this didn't work.
Did I put the trigger in the correct place?

Thanks


Two problems:
1) I'm pretty sure you can only set item_is_valid using set_item_instance_property
2) The trigger is not firing because valid is false. So how do you think the trigger is going to fire to set the property to false? Set_item_instance_property needs to go in a different trigger - when-new-record-instance would be my first choice.
Re: when-validate-item trigger doesn't fire [message #589740 is a reply to message #589730] Wed, 10 July 2013 07:20 Go to previous messageGo to next message
metal_navin
Messages: 21
Registered: February 2013
Junior Member
CM,
Sorry about my lapse in thinking there. I tried putting the code in the when-new-record-instance trigger but the didn't work as well.

The help in oracle forms is saying I can only use the set_item_property to set the item_is_valid property, as well as several checks on the net Sad

The block that the field is on is a database block.
The functionality is that for a certain utility accountnum, I can pull up a form to enter a random meter reading for the account. So when this form comes up, in it there are already populated fields, (eg previous reading, meter number etc). So when I enter the random meter reading, I have to press tab, or click on the reason code field, and enter a Reason why I wanted to post this random meter reading. Now, this REASON_CODE field is field that can either accept text from the user, or the user has the ability to select a reason code from a static list.

But as it is now.
1)The block that the field is in is a database block
2)The item itself is not a database item.

Thanks,
Re: when-validate-item trigger doesn't fire [message #589746 is a reply to message #589740] Wed, 10 July 2013 07:36 Go to previous message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
Don't have forms handy to check but it makes no sense for item_is_valid to be anything other than instance level - seeing as one record in a form might have the item as valid and another record have it as invalid.

Can you move the null check to when-validate-record? Since it's a db block that will fire.

Still don't understand why reason isn't a db item? Don't you need to save the reason_code to the same table as everything else?
Previous Topic: How to change image resolution in oracle forms.
Next Topic: I can't see the PL/SQL code while debugging a form
Goto Forum:
  


Current Time: Sat Jun 01 03:35:54 CDT 2024