Home » Developer & Programmer » Forms » Unable to delete new record because of when_new_record Trigger. (forms-9I)
Unable to delete new record because of when_new_record Trigger. [message #414467] Wed, 22 July 2009 05:16 Go to next message
pranabpranab4u
Messages: 5
Registered: July 2009
Junior Member
Hi David,
I have a form where there are multiple detail records are displayed. The Fields of the detail records are something like "Deal_no", "First_collct_date","Last_collect_date" and so on. In the Action block I have buttons called OK, Add_New_line, Delete, Cancel and so-on.
I will disable the delete button depending upon the First_collct_date. condition
1.If First_collct_date<sysdate then disable the "Delete" button.
2. If Last_collect_date < sysdate then enable "Delete" button.
3. If First_collct_date> sysdate or First_collct_dateis null (in case newly added record) then enable the "Delete" button.

Problem:
when I have the first record which is satisfies condition 1 (above) and try to add the new record. When I click on "Delete" button, the when_validate_record is fires and not able to delete the record.

Sample Code:
I have written condition 1 2 and 3 in WHEN-NEW-RECORD-INSTANCE in the detail block.
code is :

...
if (:B_fixed_deal.status = 'I' and :B_fixed_deal.collect_end_date < L_vdate) then
RWIDGET.TURN_ON('B_action.PB_delete_line');
elsif :B_fixed_deal.collect_start_date >= L_vdate or :B_fixed_deal.collect_start_date is null then
RWIDGET.TURN_ON('B_action.PB_delete_line');
else
RWIDGET.TURN_OFF('B_action.PB_delete_line');
end if;
...
Could you please suggest me who can I solve the problem.
please let me know, in case you need more info.
Thanks,
Pranab
Re: Unable to delete new record because of when_new_record Trigger. [message #414472 is a reply to message #414467] Wed, 22 July 2009 05:24 Go to previous messageGo to next message
Littlefoot
Messages: 20888
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
You could, perhaps, do something different: check all those conditions in <Delete> button's WHEN-BUTTON-PRESSED trigger. Something like this:
if your_condition_1 is true then
   message('Deleting is not allowed');
   raise form_trigger_failure;
elsif (your_condition_2 is true) or
      (your_condition_3 is true) 
then
   delete_record;
end if;
Re: Unable to delete new record because of when_new_record Trigger. [message #414479 is a reply to message #414472] Wed, 22 July 2009 05:52 Go to previous messageGo to next message
pranabpranab4u
Messages: 5
Registered: July 2009
Junior Member
Thanks for your reply. But my requirement is that in condition 1, delete button should be disabled. When My form will allow user to delete, then only it should be enabled, else disabled.

So I need to enable and disable the Delete button.

Could you please suggest me how do I implement that.
Thanks,
Pranab
Re: Unable to delete new record because of when_new_record Trigger. [message #414623 is a reply to message #414479] Thu, 23 July 2009 00:43 Go to previous messageGo to next message
pranabpranab4u
Messages: 5
Registered: July 2009
Junior Member
Can anyone please suggest me how can I implement the above problem.
Re: Unable to delete new record because of when_new_record Trigger. [message #414711 is a reply to message #414467] Thu, 23 July 2009 04:46 Go to previous messageGo to next message
blaxmi
Messages: 36
Registered: May 2008
Location: Hyderabad
Member
Hi Pranab,

I have understand your problem. Use this property to enable or disable a button at run time. In when_button_pressed trigger write the code like this

if condition1 is true then
set_item_property('<button name>',enabled/disabled, property_true/property_false);
end if;
Re: Unable to delete new record because of when_new_record Trigger. [message #414864 is a reply to message #414711] Thu, 23 July 2009 20:29 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
In 'WHEN-NEW-RECORD-INSTANCE' turn off delete and only enable it when the condition is met. You are having problems because you are not handling NULL values correctly.

David
Re: Unable to delete new record because of when_new_record Trigger. [message #414907 is a reply to message #414711] Fri, 24 July 2009 00:23 Go to previous messageGo to next message
pranabpranab4u
Messages: 5
Registered: July 2009
Junior Member
Thanks for your reply. But this code only disable the Delete button, when it is pressed and the condition is met. but it has to be something like :- if the record is not allowed to delete, then Delete button should be disabled.

Could you please any other solution where, I can disable and enable the button when ever I select any particular record.

Thanks in advance,
Pranab
Re: Unable to delete new record because of when_new_record Trigger. [message #414912 is a reply to message #414907] Fri, 24 July 2009 00:28 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
That is what I instructed you to do in my previous post. The 'WNRI' is for the block containg your records. It will fire for EVERY record as you enter it.

David
Re: Unable to delete new record because of when_new_record Trigger. [message #414923 is a reply to message #414864] Fri, 24 July 2009 01:07 Go to previous messageGo to next message
pranabpranab4u
Messages: 5
Registered: July 2009
Junior Member
Hi David,
Thanks for your reply. But I am really sorry, I am not able to understand what NULL value you are talking about. I thought you are talking about ":B_fixed_deal.collect_start_date is null"
So I modified the for testing like "elsif nvl(:B_fixed_deal.collect_start_date,'20-DEC-2009') >= L_vdate". But I got the same error.
May be I am wrong. Could you please suggest me how you are looking for handling the NULL. Also let me know If you need any more info from my end.
Thanks and Regards,
Pranab
Re: Unable to delete new record because of when_new_record Trigger. [message #415262 is a reply to message #414923] Sun, 26 July 2009 23:41 Go to previous message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Always use a to_date or to_char when testing date fields. It was to avoid this problem of date strings that I suggested turning 'off' the delete feature, without condition or exception, at the beginning of the trigger and only turning it back on if a condition is met.

David
Previous Topic: serial numbers
Next Topic: FRM-92101
Goto Forum:
  


Current Time: Fri Dec 02 19:02:43 CST 2016

Total time taken to generate the page: 0.20481 seconds