Home » Developer & Programmer » Forms » how to make a field readonly before saving (10g)
how to make a field readonly before saving [message #653275] Thu, 30 June 2016 14:07 Go to next message
lucky123
Messages: 12
Registered: June 2016
Junior Member
Hello,

I have a requirement to default first field in detail block and freeze it only the value get defaulted.

I wrote the below code in WHEN NEW REORD INSTANCE trigger.

IF get_block_property('DATA_BLOCLK',CURRENT_RECORD)=1 THEN
SET_ITEM_INSTANCE_PROPERTY('DATA_BLOCK.ITEM',CURRENT_RECORD,UPDATE_ALLOWED,PROPERTY_FALSE);
ELSE
SET_ITEM_INSTANCE_PROPERTY('DATA_BLOCK.ITEM',CURRENT_RECORD,UPDATE_ALLOWED,PROPERTY_TRUE);

This is allowing to freeze the field once it gets saved. But I need to freeze the field as soon as value gets populated.

I aslo tried below code in WHEN_VALIDATE_ITEM

IF :data_block.item1 ='VALUE' THEN
SET_ITEM_INSTANCE_PROPERTY('DATA_BLOCK.ITEM',CURRENT_RECORD,UPDATE_ALLOWED,PROPERTY_FALSE);
ELSE
SET_ITEM_INSTANCE_PROPERTY('DATA_BLOCK.ITEM',CURRENT_RECORD,UPDATE_ALLOWED,PROPERTY_TRUE);
But it does the same thing.

Is there a way to freeze the field as soon a sthe value gets populated??Please suggest
Re: how to make a field readonly before saving [message #653280 is a reply to message #653275] Thu, 30 June 2016 16:19 Go to previous messageGo to next message
Littlefoot
Messages: 21806
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
How about this (untested):
-- WHEN-NEW-ITEM-INSTANCE trigger on DATA_BLOCK.ITEM1 item

if :system.trigger_record = '1' then
   :data_block.item1 := 'VALUE';
   next_item;
   set_item_instance_property('data_block.item', current_record, update_allowed, property_false);
end if;
Re: how to make a field readonly before saving [message #653301 is a reply to message #653280] Fri, 01 July 2016 03:22 Go to previous messageGo to next message
cookiemonster
Messages: 13917
Registered: September 2008
Location: Rainy Manchester
Senior Member
You need to set insert_allowed. It's insert until the record is saved.
Re: how to make a field readonly before saving [message #653463 is a reply to message #653301] Wed, 06 July 2016 07:51 Go to previous message
lucky123
Messages: 12
Registered: June 2016
Junior Member
Thank you.Issue resolved after insert_allowed set to false.
Previous Topic: What type of triiger needs to get fired when we want to default values in text item
Next Topic: once saved make the detail block read-only
Goto Forum:
  


Current Time: Thu Mar 28 19:00:09 CDT 2024