Home » Developer & Programmer » Forms » When check box changed trigger not working (Oracle forms 10g)
When check box changed trigger not working [message #629144] Wed, 03 December 2014 15:24 Go to next message
megha2525
Messages: 62
Registered: June 2012
Location: columbus
Member
Hi All,
I am working Oracle forms 10g.I do have a master detail form . Master block is based on cards table and the detail block is based on Transactions table.
The detail block has a database column - Reviewed which is a check box.
For example,if the detail block had 4 records and the if the user checks the item 'Reviewed' for 3 records, when the user clicks the save button at the top ,
an alert should pop up.

I have set up an alert for the pop up message.
But my issue is that the pop up message is coming up all the time when the user clicks save button all the time.
Please help.

Thanks
Megha
Re: When check box changed trigger not working [message #629146 is a reply to message #629144] Wed, 03 December 2014 15:35 Go to previous messageGo to next message
CraigB
Messages: 386
Registered: August 2014
Location: Utah, USA
Senior Member
Where did you put your code for the Popup (Alert)? Can you give a code sample?

Craig...
Re: When check box changed trigger not working [message #629149 is a reply to message #629146] Wed, 03 December 2014 18:41 Go to previous messageGo to next message
megha2525
Messages: 62
Registered: June 2012
Location: columbus
Member
Hi Craig,

I have the following in the when-checkbox-changed trigger at the form level.

 if   :trans.reviewed_flag = 'Y' THEN
              
                cl_button := Show_Alert('caution');                 

                                     IF cl_button = ALERT_BUTTON1 THEN 

                                          :trans.reviewed_by := v_fullname;

                                   Set_Item_Instance_Property('TRANS.REVIEWED_FLAG',CURRENT_RECORD,UPDATE_ALLOWED,PROPERTY_FALSE);                          

                                      ElSIF cl_button = ALERT_BUTTON2 THEN

                                           Set_Item_Instance_Property('TRANS.REVIEWED_FLAG',CURRENT_RECORD,UPDATE_ALLOWED,PROPERTY_TRUE);       

                                            :trans.reviewed_flag := 'N';

                               END IF;

               end if;

on the property palette of the alert button , I have set the Button 1 Label as OK ; Button 2 Label as Cancel. Default Alert Button is set to Button 1.


Once the user checks the reviewed check box and it is saved to the database , the user cannot uncheck the reviewed check box.Hence the code.


Thanks
Megha

[Updated on: Wed, 03 December 2014 18:48]

Report message to a moderator

Re: When check box changed trigger not working [message #629157 is a reply to message #629144] Thu, 04 December 2014 00:13 Go to previous messageGo to next message
Littlefoot
Messages: 21806
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
megha2525

But my issue is that the pop up message is coming up all the time when the user clicks save button all the time.

Of course; you told it so. If you don't want to raise an alert every time you click a checkbox, then remove alert from the WHEN-CHECKBOX-CHANGED trigger and put it somewhere else.
Re: When check box changed trigger not working [message #629166 is a reply to message #629157] Thu, 04 December 2014 01:47 Go to previous messageGo to next message
megha2525
Messages: 62
Registered: June 2012
Location: columbus
Member
Hi Littlefoot,

What is the correct trigger to be used? I thought when checkbox changed trigger is fired when there is a change on the checkbox item. Though the user did not change the checkbox, it is still firing. Please suggest the correct trigger .

Thanks
Megha

[Updated on: Thu, 04 December 2014 01:47]

Report message to a moderator

Re: When check box changed trigger not working [message #629174 is a reply to message #629166] Thu, 04 December 2014 02:50 Go to previous messageGo to next message
cookiemonster
Messages: 13917
Registered: September 2008
Location: Rainy Manchester
Senior Member
when-checkbox-changed only fires when a checkbox is changed. If it's firing when the user doesn't change it then some other code is changing it.
What does this alert actually say?
Re: When check box changed trigger not working [message #629216 is a reply to message #629174] Thu, 04 December 2014 08:24 Go to previous messageGo to next message
megha2525
Messages: 62
Registered: June 2012
Location: columbus
Member
Hi Cookiemonster,

The alert is a message saying 'By clicking the reveiwed flag, you have reviewed the relevant transactions'.
Can you please suggest the right trigger ? All I am trying to do is if the detail block had 4 records and if the user checks the item 'Reviewed' for 3 records, when the user clicks the save button at the top ,
an alert should pop up.

Thanks
Megha
Re: When check box changed trigger not working [message #629218 is a reply to message #629216] Thu, 04 December 2014 08:31 Go to previous messageGo to next message
cookiemonster
Messages: 13917
Registered: September 2008
Location: Rainy Manchester
Senior Member
If you want the alert once per record - pre-update. If you want it once per save - pre-commit.
Re: When check box changed trigger not working [message #629219 is a reply to message #629218] Thu, 04 December 2014 09:19 Go to previous messageGo to next message
megha2525
Messages: 62
Registered: June 2012
Location: columbus
Member
Thank you Cookiemonster.
The pre commit trigger works as per the requirement as in it fires only once when I hit save.
This is the code I have in the pre commit trigger at form level.
declare
		cl_button NUMBER;
		v_fullname pcard.transactions.reviewed_by%type;
		v_userid   pcard.transactions.reviewed_by%type;
		
begin
	 
v_userid:=FND_PROFILE.VALUE('USER_ID');

select hr.full_name into v_fullname
from hr.per_all_people_f hr,
     applsys.fnd_user fnd
WHERE (hr.person_id = fnd.employee_id)
and fnd.user_id=v_userid
and hr.effective_end_date > sysdate;


  if   :trans.reviewed_flag = 'Y' THEN 
      	
      	cl_button := Show_Alert('caution');
      	 
      	
 	   	     IF cl_button = ALERT_BUTTON1 THEN  
 	   	          :trans.reviewed_by := v_fullname;
 	         	    Set_Item_Instance_Property('TRANS.REVIEWED_FLAG',CURRENT_RECORD,UPDATE_ALLOWED,PROPERTY_FALSE);    
 	   	
 	   	      ElSIF	cl_button = ALERT_BUTTON2 THEN
 	   	            Set_Item_Instance_Property('TRANS.REVIEWED_FLAG',CURRENT_RECORD,UPDATE_ALLOWED,PROPERTY_TRUE);   	
 	   	            :trans.reviewed_flag := 'N';
 	        	END IF;	
 	end if;
 end;


Since, I want all the 3 out of 4 records that have 'reviewed' checked to be saved to the database I put the following code in pre -update trigger at form level.
update transactions
set 
reviewed_flag = :trans.reviewed_flag,
reviewed_by = :trans.reviewed_by,
last_update_date = sysdate
where transaction_id = :trans.transaction_id; 


But it is updating only one record to the database. Which trigger should I be using to update all the 3 records to the database ? and also once a record has been saved to database as checked, it should not be unchecked again.

Please help.
Thanks
Megha

[Updated on: Thu, 04 December 2014 09:22]

Report message to a moderator

Re: When check box changed trigger not working [message #629228 is a reply to message #629219] Thu, 04 December 2014 13:28 Go to previous message
megha2525
Messages: 62
Registered: June 2012
Location: columbus
Member
Hi All,

Thanks for all the help. I resolved this using the pre update trigger and the pre commit trigger. I have the code for the alert message in the pre commit trigger and the code to update the database is in the pre update trigger and it works.

Thanks
Megha
Previous Topic: how to call database package , after saving the Data
Next Topic: How to remove the field value of a list element.
Goto Forum:
  


Current Time: Thu Mar 28 16:00:16 CDT 2024