This content has been marked as final. Show 4 replies
You can put your code in when-new-iten-instance like this.
Just make the Insert allowed and updated allowed as no in the property palette. And then write a code in the when-new-item-instance
Select count(emp_no) from table where emp_no=:block.field_name;
If count >1 then
Make it as false.
Can you show us what you have tried?
Is the item being "enabled" in a "Form layout" or "Tabular Layout"? If Form Layout, you can use the SET_ITEM_PROPERTY('ITEM_NAME',ENABLED, PROPERTY_TRUE) method. If your item is in a Tabular Layout, then you can't ENABLE or DISABLE the item because there is no built-in method for doing this. Instead, you can set the item as INSERT or UPDATE_ALLOWED as Sri indicated.
Also, it is helpful to know what Forms version you are using.
What I understand from the question is, you want the customer name field getting enabled without 'tab'bing out of customer number?
Maybe you can use the post-text trigger in the customer number field to set the properties of customer name as Sri and Craig suggested.
An alternative approach would be,
1. Keep both the items enabled.
2. In the when-new-item-instance trigger of customer name write this code -
IF <customer_num NOT valid OR customer_num IS NULL> THEN
message('FRM-XYZ Invalid Customer Number.');
This obviously, won't disable any item but serve your purpose w/o much hassles.