function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Anu Raj.ax1269Anu Raj.ax1269 

Error message displayed more than 1 time.

Hi

  I have created a VF page and in the controller it contain a list of object fields records. I have wrote a condition in it, if the condition is true then an error message should dispaly else the record should be displayed. 

 

eg: - in a object A.  i have fields b c d.

 

in a list i have the records of  b, c  and d. 

list contain 10 records. The first 3 the condition is true then  a error messag is shown else the value is dispalyes. 

 

The issue is i am getting an error message but it is diplaying 3 times according to the example. That mean it is displayes according to the number of condition gets true.

I want it to be displayed only once. 

Please help me to solve this problem.

 

Thanks

Anu 

shra1_devshra1_dev

Hi Anu Raj,

 

If you can post your code, It will be easy to solve your problem.

 

I think you need to put a break; or return null; when you add a Page message.

 

Regards,

Shravan

!!Pawan!!!!Pawan!!

 

 

You can store message in String and display the same in vf page according to your conditions 

Anu Raj.ax1269Anu Raj.ax1269

Thanks of the reply 

 

here is my code 

List<object__c> List_object =[Select .. from object];
        string errorMessage;
        ApexPages.Message myMsg;
       for(integer i = 0; i<List_object .size(); i++){
       	
       	if(List_object [i].field== False || List_object [i].field== False){
       		        // errorMessage = string.valueof(myMsg);
       		 errorMessage = 'error'; 	
             this.isDisabled = true;	
       	}      			
       	else 
       	{
       			if(List_object [i].field== true && List_object [i].field== true)
       			List_HDAPItems.add(List_object [i]);
        }
       		
       	
       }
         myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, errorMessage); 
         ApexPages.addMessage(myMsg);
      
    }

 Thanks

Anu

Anu Raj.ax1269Anu Raj.ax1269

Thanks guys for spending your time for me. I have solved the issue. It was related to VF page.

 

Thanks

Anu