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
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 ChinchinadaNagendra Chinchinada
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 ChinchinadaNagendra Chinchinada
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 ChinchinadaNagendra Chinchinada
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