Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am getting an error "No such column 'name' on entity 'Task'. It is coming from my query but I am not querying for 'name'. Please help.

public list<task> getTasks() {
list<account> myaccs = new list<account>([select id from account where ownerid =: userinfo.getuserid()]);
set<id> aid = new set<id>();
for(account a: myaccs){

string sortFullExp = sortfield  + ' ' + sortDirection;
    mytasks = database.query('SELECT subject, status, priority, reminderdatetime from task order by ' + sortFullExp);
    return mytasks;
share|improve this question
up vote 4 down vote accepted

I bet that the value of 'sortfield' is 'Name'. Use System.debug('sortfield val = ' + sortfield); and see what comes up.

share|improve this answer
You are correct. 'Name' was assigned to sortfield. – Berg Feb 13 '14 at 19:30
If this is the correct answer, could you please mark it as such? – dphil Feb 13 '14 at 19:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.