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
Rahul MahaleRahul Mahale 

Data changed by trigger for field Status: data value too large: (value has been hidden)

Hello All,

I have written following code in apex class:

public class StudentSelection {
    Public Static Void StudentSelectionCriteria(List<Student__c> StudentListNew){
        for(Student__c S : StudentListNew){
            if (S.Age__c<=30 && S.Experience__c>8){
                S.Status__c='Selected';
            }
            else if(S.Age__c>30 && S.Experience__c<8){
                S.Status__c='Not Selected';
            }
           
      }       
  }
}

Trigger :
trigger StudentSelectionTrigger on Student__c (before insert) {
    
    if(Trigger.isBefore==True && Trigger.isInsert==True){
        
       StudentSelection.StudentSelectionCriteria(Trigger.New);
    }

}

Can you check while satisfying not selected condition i am gettin error:

StudentSelectionTrigger: data changed by trigger for field Status: data value too large: (value has been hidden)

Also can we use only else instead of if else??
Shatrughna SalunkeShatrughna Salunke
HI Rahul,

Plese chek with below article.

https://help.formassembly.com/help/salesforce-error-data-value-too-large

Also, we use else condtion instead of  if else 

Many Thanks,
Shatrughna Salunke 
 
Tom Stewart 137Tom Stewart 137
HI ! did you get the solution for this ? i am struggling with the same. 
Shams TabrezShams Tabrez
Hi Rahul & Tom,

The code is working well for me.
Datatypes used for the fields: Age-Formula, Experience-Number, and Status-Picklist.

Also, FYI- we cannot use only ' else ' instead of ' else if '. If you want to use only ' else ' then use the below code.
Conditional statements are not allowed if you are using only ' else '.

TriggerHelper:
public class StudentSelection {    
    Public Static Void StudentSelectionCriteria(List<Student__c> StudentListNew){
        for(Student__c S : StudentListNew){
            if(S.Age__c<=30 && S.Experience__c>8){
                S.Status__c='Selected';
            }
            else{
                S.Status__c='Not Selected';
            }            
        }       
    }
}

Trigger:
trigger StudentTrigger on Student__c (before insert){    
    if(Trigger.isBefore && Trigger.isInsert){        
        StudentSelection.StudentSelectionCriteria(Trigger.New);
    }    
}

Thanks & Regards,
​​​​​​​Shams Tabrez