+ Start a Discussion

How i reteive the ID from APex?



I Apex Class I m using,


List<Class__c> r =[SELECT Day_of_Week__c,end_Time__c,start_Time__c,teacher_Name__c,Name from Class__c WHERE teacher_Name__c =:teachername];
Class__c r1;
r1=new Class__c(Name=r[0].Name);
   return r[0];
   return new Class__c();

 in above coding Query area i m using Teacher Name, but that query is return null value. But tha table have a value.


               After that I using delevloper console, there only i found one problem. normally the query return the Id value of Teacher's name.. So i seraching the Id value from Teacher Name's Tables but I cant find out it. So I dont know how to use teacher name , how to reterive the ID form Apex...??


NULL Value Return Code:

getClassName.Class__c getClassNameResponse = getClassNameObj.getClassFromTeacherName(Session["Username"].ToString());

 Value Return Code ( Another try)

getClassName.Class__c getClassNameResponse = getClassNameObj.getClassFromTeacherName("0039000000CYPbNAAX");



is teachername blank or otherwise invalid?  that could cause null results when the table contains data . . . .