• Rahul Mahale
  • NEWBIE
  • 10 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
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??
I need to print in O/P of  Stored values in Keys & Associated values line by line of Map function.

o/p required :

the current key =98
the current value for above key = Robert

What enhancement should i do to achieve o/p?

Code :

//Declare Map Variable & Show key Values, Values & Check if it is empty or not.

Map<integer, String> VarMapOfEmployeeMobileNum= New Map <integer, String>();

//add some items
VarMapOfEmployeeMobileNum.put(98,'Robert');
VarMapOfEmployeeMobileNum.put(64,'Matthew');
VarMapOfEmployeeMobileNum.put(55,'Harry');

//to see the map
System.debug('The current map ='+VarMapOfEmployeeMobileNum);


//Collect all Keys and Show 1 By 1
set<Integer> VarTempSet = new set<Integer>();
VarTempSet = VarMapOfEmployeeMobileNum.keyset();
for (integer VarMobileSetPrint: VarTempSet)
{
    system.debug('The Current Key ='+VarMobileSetPrint);
}

//Collect all Values and Show 1 By 1
List<String> VarTempList = new List<String>();
VarTempList = VarMapOfEmployeeMobileNum.Values();
for (string VarMobileListPrint: VarTempList)
{
    system.debug('The Current Value for above Key ='+VarMobileListPrint);
}
 
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??
I need to print in O/P of  Stored values in Keys & Associated values line by line of Map function.

o/p required :

the current key =98
the current value for above key = Robert

What enhancement should i do to achieve o/p?

Code :

//Declare Map Variable & Show key Values, Values & Check if it is empty or not.

Map<integer, String> VarMapOfEmployeeMobileNum= New Map <integer, String>();

//add some items
VarMapOfEmployeeMobileNum.put(98,'Robert');
VarMapOfEmployeeMobileNum.put(64,'Matthew');
VarMapOfEmployeeMobileNum.put(55,'Harry');

//to see the map
System.debug('The current map ='+VarMapOfEmployeeMobileNum);


//Collect all Keys and Show 1 By 1
set<Integer> VarTempSet = new set<Integer>();
VarTempSet = VarMapOfEmployeeMobileNum.keyset();
for (integer VarMobileSetPrint: VarTempSet)
{
    system.debug('The Current Key ='+VarMobileSetPrint);
}

//Collect all Values and Show 1 By 1
List<String> VarTempList = new List<String>();
VarTempList = VarMapOfEmployeeMobileNum.Values();
for (string VarMobileListPrint: VarTempList)
{
    system.debug('The Current Value for above Key ='+VarMobileListPrint);
}