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
Devendra Hirulkar 3Devendra Hirulkar 3 

Variable does not exist: Student__c.class__r

Hi all
Variable does not exist: Student__c.class__r
this error has occur in my trigger please tell me what is problem
here is my trigger


trigger copyying on class__c (after insert)
{
    List<Student__c> parentObjList = new List<Student__c>();
    List<Id> listIds = new List<Id>();
    for (class__c childObj : Trigger.new) 
    {  
        listIds.add(childObj.Student__c);
    }

    parentObjList = [SELECT id,Name,(SELECT ID, Roll_No__c FROM class__r) FROM Student__c WHERE ID IN :listIds];

    for (Student__c opp : parentObjList)
    {
        for (class__c quote: Student__c.class__r)
        {
            opp.Roll_No__c = quote.Roll_No__c;
        }
    update parentObjectList;
     }
}    
thanks 
Deoo   
Kunal BindalKunal Bindal

Instead of

for (class__c quote: Student__c.class__r)

Use this
for (class__c quote: opp.class__r)