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
RiyajRiyaj 

How do i get original text when executing in Apex Query....????

Hi

 

I m using following Apex Class code...

 

---------------------------------------------------------------------------------------------------------
List<Attendance__c> r=[SELECT Id,attendance_Date__c,attendance_Roll__c,Remarks__c,student_Name__c FROM Attendance__c WHERE classname__c='Learn Corn' AND attendance_Date__c=2012-05-12];

Attendance__c r1;
if(r.size()>0)
{
r1=new Attendance__c(Id=r[0].Id);
return r[0];
}
else
return new Attendance__c();

---------------------------------------------------------------------------------------------------------

My table records
---------------------------------------------------------------------------------------------------------

Id : a0590000002LE9sAAG
ClassName : Learn Corn -- From Look up
Attendance Date : 5/12/2012
Attendance Roll : Present
Remarks : Hello
Student Name : Gio -- From Look up

---------------------------------------------------------------------------------------------------------

but when i debug it is not working, rather than return values are like

---------------------------------------------------------------------------------------------------------

Id : a0590000002LE9sAAG
ClassName : Learn Corn
Attendance Date : 1336780800000
Attendance Roll : Present
Remarks : Hello
Student Name : 0039000000CYP14AAH
Class Name : a0390000002vWW9AAM
---------------------------------------------------------------------------------------------------------

How do i get original text when executing in Apex Query....????

 

Best Answer chosen by Admin (Salesforce Developers) 
kiranmutturukiranmutturu

Id : a0590000002LE9sAAG
ClassName : Learn Corn
Attendance Date : 1336780800000
Attendance Roll : Present
Remarks : Hello
Student Name : 0039000000CYP14AAH// here u need to use student_name__r.name if the look up field name is student_name__c
Class Name : a0390000002vWW9AAM// same as above...class_name__r.name

All Answers

kiranmutturukiranmutturu

Id : a0590000002LE9sAAG
ClassName : Learn Corn
Attendance Date : 1336780800000
Attendance Roll : Present
Remarks : Hello
Student Name : 0039000000CYP14AAH// here u need to use student_name__r.name if the look up field name is student_name__c
Class Name : a0390000002vWW9AAM// same as above...class_name__r.name

This was selected as the best answer
Abhay AroraAbhay Arora

When you use a relationship name in a query, you must use the relationship names without the__c. Instead, append an__r

(underscore underscore r).

 

 

SELECT Id, FirstName__c, Mother_of_Child__r.FirstName__c
FROM Daughter__c
WHERE Mother_of_Child__r.LastName__c LIKE 'C%'

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_relationships.htm#topic-title

 

This is what you need to refer please mark as solved if above is what you need

RiyajRiyaj

Thank you... It is working fine...

but the Date field return only the Id.... what can I do for get the Date....????