+ Start a Discussion
TracMikeLTracMikeL 

Validation Error on VF Page

 

We are getting the following error when viewing a custom VF page. We have NO validation on the page or the object.
There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Subject: data value too large: Call Logged with Overlin Zamora RE: Pittsburg High School Reconstruction/Modernization (max length=80)". 
Here is my Apex code for that page 
SObject[] ClosedTasks = [SELECT (SELECT Id, WhatId, WhoId, LastModifiedDate, Subject, Who.Name, ActivityDate, Status, Priority, Owner.Name, Description, IsTask 
FROM ActivityHistories ORDER BY ActivityDate DESC, LastModifiedDate DESC LIMIT 500) 
FROM Opportunity WHERE Id = :o.Id];

myClosedTasks = (List<ActivityHistory>)ClosedTasks.get(0).getSObjects('ActivityHistories');

 

And here is the VF page.

 

 

<apex:page standardController="Opportunity" extensions="trac_Activity_History">

	<apex:form >
	<apex:pageBlock >
	<apex:pageBlockSection collapsible="false" title="Activity History" columns="1">
	
		<apex:pageBlockTable value="{!myClosedTasks}" var="t">
		
                    <apex:column headerValue="Action" width="75px" rendered="{!if(t.IsTask,'true','false')}">                    
                       <a href="{!URLFOR($Action.Task.Edit, t.Id,[retURL=URLFOR('/apex/ActivityHistory?Id='+ t.WhatId)])}" target="_top">Edit</a>
                    </apex:column>
                    <apex:column headerValue="Action" width="75px" rendered="{!if(t.IsTask,'false','true')}">                    
                       <a href="{!URLFOR($Action.Event.Edit, t.Id,[retURL=URLFOR('/apex/ActivityHistory?Id='+ t.WhatId)])}" target="_top">Edit</a>
                    </apex:column>
                    <apex:column value="{!t.IsTask}"/>
                    <apex:column headerValue="Name">
                        <apex:outputLink target="_top" value="/{!t.WhoId}">{!t.Who.Name}</apex:outputLink>
                    </apex:column>
                    <apex:column value="{!t.ActivityDate}"/>
                    <apex:column headervalue="Assigned To">
                        <apex:outputLink target="_top" value="/{!t.OwnerId}">{!t.Owner.Name}</apex:outputLink>
                    </apex:column>
                    <apex:column value="{!t.Status}"/>
                    <apex:column headerValue="Subject" value="{!t.Subject}" />
                    <apex:column headerValue="Comments">
                    	<apex:outputText >{!t.Description}</apex:outputText>
                    </apex:column>                    
		
		</apex:pageBlockTable>
	
	</apex:pageBlockSection>
	</apex:pageBlock>
	</apex:form>
	
</apex:page>

 

Why would this error occur? Seems odd.

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
TracMikeLTracMikeL

I found a way that works for this.

 

If I use this for the column

                    <apex:column headerValue="Subject">
                    	<apex:outputText >{!t.Subject}</apex:outputText>
                    </apex:column>

 

 

instead of

 

 

<apex:column headerValue="Subject" value="{!t.Subject}" />

 

It works.

 

 

All Answers

Rajesh ShahRajesh Shah
It seems a field of type text (having a size of 80) is having a data of more than 80 chars.
Bhawani SharmaBhawani Sharma

Hi Rajesh,

 

Is it ? From the code snippet it seems that data is only populating from the database. SO it should not throw any exception.

TracMikeLTracMikeL

You are correct, it is just pulling data. There is NO validation.

 

Subject is a standard field on Activities so I have no idea why its complaining about this. It's not like we can change the length of that field.

TracMikeLTracMikeL

I found a way that works for this.

 

If I use this for the column

                    <apex:column headerValue="Subject">
                    	<apex:outputText >{!t.Subject}</apex:outputText>
                    </apex:column>

 

 

instead of

 

 

<apex:column headerValue="Subject" value="{!t.Subject}" />

 

It works.

 

 

This was selected as the best answer
Bhawani SharmaBhawani Sharma

Unbelievable , it works in this manner .

David81David81

Just a quick note to anyone who might find this thread in the future.

 

I had the same problem when trying to use

 

 

<apex:column headerValue="Subject">
     <apex:outputField value="{!t.Subject}" />
</apex:column>

 

 

but using

 

 

<apex:column headerValue="Subject" value="{!t.Subject}" />

 

 

didn't work for me.

 

Oddly enough, I had to use

 

 

<apex:column headerValue="Subject">
	<apex:outputText value="{!t.Subject}" />
</apex:column>

 and that works. Go figure.