Home » Developer & Programmer » Forms » Check box not selecting the correct value (Oracle Forms : 12c (12.2.1.4.0);Fusion Middleware: fmw_12.2.1.4.0 and O/S: Windows 10 pro 64 bit)
Check box not selecting the correct value [message #679247] Tue, 18 February 2020 15:58 Go to next message
buggleboy007
Messages: 282
Registered: November 2010
Location: Canada
Senior Member
I am trying to fix a bug where in if a user selects 'NO' on an alert, then a check box by name SELECT (:WEB_CATALOGUES.CHECK_IND) should be checked or set to Y. However that is not what is happening. It checks another check box called 'PURGE'(:WEB_CATALOGUES.DE_ACTIVATED_IND) gets checked. Here's how the code works.

I press a button called UNCHECK and it fires this trigger (when-button-pressed)

IF :CRITERIA.SITE_ID IS NULL THEN 
  rams$msg_ofg45('E', TRUE, '709304%1Web site');
END IF;

IF :WEB_CATALOGUES.STYLE_ID IS NULL OR :WEB_CATALOGUES.COLOR_ID IS NULL THEN 
  rams$msg_ofg45('E', TRUE, 720011);	
END IF;  


BEGIN
	--d71883 18-FEB-2020 start
	 :cg$ctrl.CG$CNTR:=0;
	 --d71883 18-FEB-2020  end
	go_block('WEB_CATALOGUES');
  first_record;
   LOG_OUTPUT ('SANDEEP W-B-P trigger before LOOP');
  LOOP
   
    :WEB_CATALOGUES.CHECK_IND :='N';    	   	
    :WEB_CATALOGUES.DE_ACTIVATED_IND :='Y';  
    LOG_OUTPUT ('SANDEEP W-B-P trigger INSIDE LOOP');
    LOG_OUTPUT('SANDEEP- STATUS OF TO PURGE(DE-ACTIVATED_IND) IS: '|| :WEB_CATALOGUES.DE_ACTIVATED_IND);
		LOG_OUTPUT('SANDEEP- STATUS OF SELECT(CHECK_INDICATOR) IS: '|| :WEB_CATALOGUES.CHECK_IND);--Using this FOR LOGGING purposes and this is the one that is over-riding the code from when-validate-block 
                                                                                               
   IF :system.last_record <> 'TRUE'
    THEN
      next_record;
    ELSE
      EXIT;
    END IF;
  END LOOP;
  first_record;
END;
Then an alert is displayed on another block called - WEB_CATALOGUES, and then the following code fires under 'WHEN-VALIDATE-RECORD'

DECLARE
	alb NUMBER;
	t_error_text varchar2(250);
  v_result number; 	
  intCnt   NUMBER;
  
 BEGIN
	 IF :WEB_CATALOGUES.STYLE_ID IS NOT NULL THEN
	 	
	    	IF :WEB_CATALOGUES.DISPLAY_FROM_DATE IS NULL THEN 
	  			rams$msg_alert('709304%1From Date','E',true);
	  		END IF;
	  
	  		IF :WEB_CATALOGUES.DISPLAY_TO_DATE IS NULL THEN 
	  			rams$msg_alert('709304%1To Date','E',true);
	  		END IF;	

	  	  IF :WEB_CATALOGUES.CHECK_IND = 'N' AND :SYSTEM.RECORD_STATUS = 'INSERT'	THEN 
	  	  	Set_Record_Property(get_block_property('WEB_CATALOGUES', CURRENT_RECORD), 'WEB_CATALOGUES', STATUS, QUERY_STATUS);
	  	  END IF;
	  		 	
			  	IF :WEB_CATALOGUES.CHECK_IND = 'N' AND :SYSTEM.RECORD_STATUS = 'CHANGED' THEN
			  		--d71883 18-FEB-2020  start
			  		
			  	   WHILE (:cg$ctrl.CG$CNTR)=0
			  	   	LOOP
			  	  --d71883 18-FEB-2020  end
			  	   		  t_error_text:= lmsg.look_message(720004, :global.language_name);
			  	   		  set_alert_property('CG$ASK_COMMIT', alert_message_text, t_error_text);
			  	   	    alb := show_alert('CG$ASK_COMMIT');
			  	   	      IF 	alb = alert_button1 THEN
							       	   NULL;	          
			  	   	      ELSIF alb = alert_button2  THEN
			  	   	      --d71883 18-FEB-2020  start	
			  	   	      	WHILE (:cg$ctrl.CG$CNTR)=0
			  	   	      	LOOP
			  	   	      		 intCnt:=GET_BLOCK_PROPERTY('WEB_CATALOGUES', QUERY_HITS);		
			  	   	      		 FOR i IN 1..intCnt
			  	   	      		 LOOP		  	   	      		
			  	   	      		 		IF :WEB_CATALOGUES.DE_ACTIVATED_IND IN('Y', 'N') THEN
			  	   	      		    	 :WEB_CATALOGUES.CHECK_IND:='Y';
			  	   	      		    	 :WEB_CATALOGUES.DE_ACTIVATED_IND:='N';
			  	   	      		 		END IF;			  	   	      		 	
			  	   	      		 		END LOOP;
			  	   	      		:cg$ctrl.CG$CNTR:=:cg$ctrl.CG$CNTR+1;
			  	   	      	 --d71883 18-FEB-2020  end 	
			  	   	      	   RAISE FORM_TRIGGER_FAILURE;
			  	   	      	 END LOOP;
			  	   	      END IF;	
			  	   	  --d71883 18-FEB-2020  start    
 			  	   	    :cg$ctrl.CG$CNTR:=:cg$ctrl.CG$CNTR+1;
			  	   	   END LOOP; 	
			  	   	 --d71883 18-FEB-2020  end
			  	END IF; 	
	   	  ELSE 
	    rams$msg_ofg45('E', TRUE, 720011);	
	 END IF;  
END;

If you notice towards the end, I am forcing the check box (:WEB_CATALOGUES.CHECK_IND) to set to Y and the other one to a N. However the code under WHEN-BUTTON-PRESSED is over riding and does not display results correctly.
Is there any way around this?
Re: Check box not selecting the correct value [message #679259 is a reply to message #679247] Wed, 19 February 2020 04:22 Go to previous messageGo to next message
cookiemonster
Messages: 13917
Registered: September 2008
Location: Rainy Manchester
Senior Member
This needs more details:
What blocks have you got?
Which block is the button on?
Which alert?

The loops in the WVR trigger make no sense:
The two WHILE loops will both iterate once each
The FOR loop does exactly the same thing no matter how many times it iterates.

So by the looks of it none of them should exist as it stands.
Re: Check box not selecting the correct value [message #679260 is a reply to message #679259] Wed, 19 February 2020 05:29 Go to previous messageGo to next message
buggleboy007
Messages: 282
Registered: November 2010
Location: Canada
Senior Member
cookiemonster wrote on Wed, 19 February 2020 04:22
This needs more details:
What blocks have you got?
Which block is the button on?
Which alert?

The loops in the WVR trigger make no sense:
The two WHILE loops will both iterate once each
The FOR loop does exactly the same thing no matter how many times it iterates.

So by the looks of it none of them should exist as it stands.
The reason why I inserted a WHILE loop was because when the application 'checks' a check box called 'PURGE', it keeps showing the alert for every record in the block and that's not how it should behave. This is where I have incorporated the WHILE loop. WHILE loop checks for the loop counter and if it's 0 only then it fires the ALERT once. If greater than 0 then it comes it. So I would disagree with you to remove it. (Since the application is buggy, my job is to fix this application).

The FOR loop, I have inserted only for testing purposes. Now that I know 'WHEN-BUTTON-PRESSED' trigger is overwriting the values it makes no sense to have FOR LOOP. I will remove it. The only idea that I have at the moment is:

a) create a global variable and set it's count to 1 and using this value adjust the code in 'WHEN-BUTTON-PRESSED' trigger so that this trigger fires correctly.

If you have any better idea than this let me know.
Re: Check box not selecting the correct value [message #679262 is a reply to message #679260] Wed, 19 February 2020 06:04 Go to previous messageGo to next message
cookiemonster
Messages: 13917
Registered: September 2008
Location: Rainy Manchester
Senior Member
1) Stop using names that aren't present in the code - i.e. purge - I assume that's the name on screen, but we can't see that so it's just confusing. Stick to the actual item name in the datablock.
2) You've got two WHILE LOOPS of the form:
WHILE (:cg$ctrl.CG$CNTR)=0

Inside both loops you do
:cg$ctrl.CG$CNTR:=:cg$ctrl.CG$CNTR+1

Which will make the WHILE condition no longer true.
So unless the code inside the loops causes some other code to fire that modifies cg$ctrl.CG$CNTR those loops will end after the first pass. And if that's true they should be IF statements not loops.
If they can actually loop then I'd say the code is too complex (relying on other triggers to allow the loop to loop is a recipe for confusion).
Re: Check box not selecting the correct value [message #679267 is a reply to message #679262] Wed, 19 February 2020 13:37 Go to previous messageGo to next message
buggleboy007
Messages: 282
Registered: November 2010
Location: Canada
Senior Member
I have resolved this issue by making changes in WHEN-BUTTON-PRESSED trigger by launching the alert there rather than in WHEN-VALIDATE-RECORD trigger and then processing the logic besides deleting the redundant code from WHEN-VALIDATE-RECORD trigger.
That has fixed the issue.
Re: Check box not selecting the correct value [message #679292 is a reply to message #679267] Thu, 20 February 2020 02:48 Go to previous message
cookiemonster
Messages: 13917
Registered: September 2008
Location: Rainy Manchester
Senior Member
Glad you got it working
Previous Topic: sending email from forms with report in pdf as an attachment
Next Topic: Mouse navigation validatation
Goto Forum:
  


Current Time: Thu Mar 28 05:18:30 CDT 2024