This content has been marked as final. Show 18 replies
MAHA REDDY wrote:hi, Maha
i am using this set custom property when press the find button " FRm-40741: unable to locate record 11 on block " error getting.
If :XXEAM_SHUTDOWN_DETAILS.WF_STATUS = 'Not Submited Yet!' then
Set_Custom_Property('XXEAM_SHUTDOWN_DETAILS.WORK_ORDER_NO', :SYSTEM.TRIGGER_RECORD, 'ENABLED', TRUE);
Set_Custom_Property('XXEAM_SHUTDOWN_DETAILS.ESTIMATED_START_DATE',:SYSTEM.TRIGGER_RECORD, 'ENABLED', TRUE);
You can try Set_item_property.
Hope this helps
It was already mentioned, but you can use SET_ITEM_PROPERTY on items and buttons as long as you are not navigated to that item or button when you set it.
Once you set an item to ENABLED property false it propagates and does the following (see help):
SET_ITEM_PROPERTY('BLOCK_NAME.FIELD_NAME', ENABLED, PROPERTY_FALSE); -- BLOCK_NAME = name of your block/FIELD_NAME the name of your field SET_ITEM_PROPERTY('BLOCK_NAME.BUTTON_NAME', ENABLED, PROPERTY_FALSE); -- BUTTON_NAME = name of your button
sets the Navigable item property to False
sets the Update_Null item property to False
sets the Updateable item property to False
Which means when you re-enable the item or the button you have to change those properties back to PROPERTY_TRUE as well.
Well, I started to explain that the use of :SYSTEM.TRIGGER_RECORD in a When-Button-Pressed (WBP) trigger might be the cause, but I have a sample form where I use the SET_CUSTOM_PROPERTY() built-in to make items VISIBLE=false so I was able to duplicate the error that you are getting.
In my sample form, the Set_Custom_Property() built-in still works even though the Error is reported; every-other record I hide an item - or in your case, disabled an item. I played around with my sample form but was unable to determine the cause of the error. As much as I hate to say this, the way I was able to elimiate the error was by simply ignoring it ( I hate to do this, I would much rather find the cause of the error and eliminate the cause then to supress errors). Consequently, I was able to eliminate the error by adding a Block level ON-ERROR trigger and testing the ERROR_CODE variable to see if it is 40741. If you have a higher level ON-ERROR trigger, you will need to change the Executeion Hierarchy property of all ON-ERROR triggers so each trigger will fire correctly. For example, in my sample form I changed the Block.ON-ERROR trigger Execution Hierarchy property to BEFORE and my Module/Form.ON-ERROR property to AFTER. This makes it so both triggers will fire. Here is the code is used in my Block.On-Error trigger.
By the way, I also changed my sample form and used the 'ENABLED' property instead of the 'VISIBLE' property and it worked just fine so you can continue to use the SET_CUSTOM_PROPERTY() built-in instead of having to use the Set_Item_Instance_Property or Set_Item_Property built-ins.
IF ( ERROR_CODE = 40741 ) THEN null; END IF;
Hope this helps,
MAHA REDDY wrote:Hi, Maha
Hi HamidHelal ,
Set_item_property. wont work record wise . i want to record wise disabled enabled button.
The only help i can do.. is enabling and disabling a button
hope this helps...
SET_CUSTOM_PROPERTY doesn't take the logical record-number as parameter, but the "physical row number" in the layout. So, if you have ten visible rows in your layout, you can give the numbers from 1 to 10 to SET_CUSTOM_PROPERTY. But SYSTEM.TRIGGER_RECORD contains the number of the record adn that can be larger than 10 (when you start scrolling).
That said, you will have difficulties to do a record-wise enabled/disabling of items in a block. You would have to "re-caclulate" the setting on each record-change, including the blocks topmost-record in the calculation of the parameter you pass to SET_CUSTOM_PROPERTY.
I have problem also with using set_custom_property in tabular to enabled/disabled button or check box (im not using :system.Trigger_record), if used in post-query trigger it will work on the first displayed queried record but if you tried to scroll down or navigate down for new record then this error arise cannot find the specified record number, i tried also to suppress this error but i have procedure to run when new_record_instance then it will not fire.
So better used what they suggest using set_item_property, my case i hide this item or i made it not updateable/updateable.
Then if you used in a button then put validation code when_button_press trigger under the button.
Rather than use Set_Custom_Property, you can create text items that look like buttons. Then use Set_Item_Instance_Property to change the visual_attribute and border_bevel on the items, and get them to appear as if they are buttons that are enabled or disabled. Then, use a When-Mouse-Click trigger instead of When-Button-Pressed to effect a button press.
Within the WMC trigger, you would probably need to re-check the same logic used to determine whether a button-press should be allowed, since the When-Mouse-Click trigger will run no matter what the visual attribute is on the item.
If you use this method, you aren't stuck with trouble when the user scrolls the block, but the Set_Custom_Property still affects the original visible rows of the block.
I finally got a few minutes to play with my sample form and discovered that Andreas is correct when he stated:
SET_CUSTOM_PROPERTY doesn't take the logical record-number as parameter, but the "physical row number" in the layout.In my sample form, as I scrolled through the records the "Enabled" items did not change with the records.
*@Maha,* my apologies. In order to implement the affect you desire, you will have to mimic the Enabled/Disabled property for each record by using a combination of the Set_Item_Instance_Property() built-in and the INSERT_ALLOWED, UPDATE_ALLOWED, NAVIGABLE, and VISUAL_ATTRIBUTE (optional) properties. Because you have modify so many properties, I wrap this in a procedure called ENABLE_ITEM and pass the Item, Record Number and Enable parameters. For example:
You then call the ENABLE_ITEM procedure in your code passing the name, record number, and enable (true or false) to disable your item. For example:
/* This procedure assumes you have a VISUAL_ATTRIBUTE */ /* created called 'ENABLED' and 'DISABLED'. In my example, */ /* I created the DISABLED visual attribute with following properties: */ /* Foreground Color = DarkGray */ /* Background Color = gray12 */ /* The ENABLED visual attribute does not specify any properties so it */ /* sets the above properties back to <Unspecified> */ PROCEDURE enable_item (inItem VARCHAR2, inRecord NUMBER, inEnabled BOOLEAN )IS paramCount NUMBER := 0; BEGIN IF ( inEnabled ) THEN Set_Item_Instance_Property(inItem, inRecord, INSERT_ALLOWED, PROPERTY_TRUE); Set_Item_Instance_Property(inItem, inRecord, UPDATE_ALLOWED, PROPERTY_TRUE); Set_Item_Instance_Property(inItem, inRecord, NAVIGABLE, PROPERTY_TRUE); Set_Item_Instance_Property(inItem, inRecord, VISUAL_ATTRIBUTE, 'ENABLED'); ELSE Set_Item_Instance_Property(inItem, inRecord, INSERT_ALLOWED, PROPERTY_FALSE); Set_Item_Instance_Property(inItem, inRecord, UPDATE_ALLOWED, PROPERTY_FALSE); Set_Item_Instance_Property(inItem, inRecord, NAVIGABLE, PROPERTY_FALSE); Set_Item_Instance_Property(inItem, inRecord, VISUAL_ATTRIBUTE, 'DISABLED'); END IF; END enable_item;
The options Francois and Steve mentioned are also good ways to do this as well.
If :XXEAM_SHUTDOWN_DETAILS.WF_STATUS = 'Not Submited Yet!' then enable_item('XXEAM_SHUTDOWN_DETAILS.WORK_ORDER_NO', :SYSTEM.TRIGGER_RECORD, TRUE); enable_item('XXEAM_SHUTDOWN_DETAILS.ESTIMATED_START_DATE',:SYSTEM.TRIGGER_RECORD, TRUE); end if;
Sorry if I confused the issue earlier.
To those that suggested using SET_ITEM_PROPERTY('BLOCK_NAME.ITEM_NAME',ENABLED, PROPERTY_FALSE), don't forget the cascade affect of setting the ENABLED property of an item to false. When you ENABLE your item later, you have to also set the NAVIGABLE, UPDATE_NULL, UPDATEABLE properties to TRUE.
Edited by: CraigB on Jan 16, 2013 2:15 PM
Hi CraigB ,
Thanks For Help it is working. but at the same time SEND button also need to disabled record wise. i have writen like this..
If :XXEAM_SHUTDOWN_DETAILS.WF_STATUS = 'Not Submited Yet!' then
enable_item('XXEAM_SHUTDOWN_DETAILS.WORK_ORDER_NO', :SYSTEM.TRIGGER_RECORD, TRUE);
else :XXEAM_SHUTDOWN_DETAILS.WF_STATUS = 'APPROVED' then
enable_item('XXEAM_SHUTDOWN_DETAILS.SEND', :SYSTEM.TRIGGER_RECORD, FALSE);
Is it possible record wise disable/enable button .