when-validate-item trigger doesn't fire [message #589639] |
Tue, 09 July 2013 05:38 |
|
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 #589700 is a reply to message #589677] |
Wed, 10 July 2013 02:34 |
cookiemonster
Messages: 13938 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 #589730 is a reply to message #589721] |
Wed, 10 July 2013 06:36 |
cookiemonster
Messages: 13938 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 |
|
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
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 |
cookiemonster
Messages: 13938 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?
|
|
|