+ Start a Discussion
Ashritha ReddyAshritha Reddy 

hii can any one plase explain how to writ a trigger for below scenario?

I have one scenario: In a class of students starting from alfabets a A TO Z ,if i select an alfabet M....i need the student name staring with M and with their marks in ascending order...how i will achieve this by using trigger
Best Answer chosen by Ashritha Reddy
Nagendra Prasad ChNagendra Prasad Ch
Small correction, It's order by Marks__c,
 
String Letter = 'M'; // Set your Starting letter dynamically here
String NameLetter = Letter+'%';
List<Class_students__c> StudentsList = [SELECT Id,Name,Marks__c FROM Class_students__c WHERE Name Like :NameLetter ORDER BY Marks__c ASC];

 

All Answers

Nagendra Prasad ChNagendra Prasad Ch
Keep this code in your trigger
 
String Letter = 'M'; // Set your Starting letter dynamically here
String NameLetter = Letter+'%';
List<Class_students__c> StudentsList = [SELECT Id,Name,Marks__c FROM Class_students__c WHERE Name Like :NameLetter ORDER BY Name ASC];

 
Nagendra Prasad ChNagendra Prasad Ch
Small correction, It's order by Marks__c,
 
String Letter = 'M'; // Set your Starting letter dynamically here
String NameLetter = Letter+'%';
List<Class_students__c> StudentsList = [SELECT Id,Name,Marks__c FROM Class_students__c WHERE Name Like :NameLetter ORDER BY Marks__c ASC];

 
This was selected as the best answer