You need to sign in to do that
Don't have an account?
Controller List object query
public class emailController { List<EmailMessage> emails = [select id,ParentId, Parent.Owner.Name,Parent.IsClosed, Parent.ClosedDate,status,fromaddress,toaddress,messagedate,subject from emailMessage where status ='0'
and (Parent.IsClosed = false or emailMessage.CreatedDate > Parent.ClosedDate) order by Parent.IsClosed asc, messagedate desc ]; public List<EmailMessage> getEmails() { return emails; } }
The above class works nicely without the red addition, but when I add this additional part I get an error "unexpected token: 'Parent.ClosedDate".
What is wrong with comparing one date to another date? If I compare either date to something like "LAST_WEEK" then the query will work, but not to each other.
How can I accomplish comparing these dates against each other in the WHERE clause just like I would in regular SQL?
Much appreciated!
Hey
The syntax is a bit off. Try putting : before Parent.ClosedDate i.e.
and (Parent.IsClosed = false or emailMessage.CreatedDate > Parent.ClosedDate)
becomes
and (Parent.IsClosed = false or emailMessage.CreatedDate > :Parent.ClosedDate)
Cheers,
Wes
Hi RDN_LHR,
did you resolve this issue? I'm struggling with the same..
Thanks,
Guy