Take the 2-minute tour ×
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.

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){
    aid.add(a.id);
    }

string sortFullExp = sortfield  + ' ' + sortDirection;
    mytasks = database.query('SELECT subject, status, priority, reminderdatetime from task order by ' + sortFullExp);
    return mytasks;
}
share|improve this question
add comment

1 Answer

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. –  SFDC NOOB Feb 13 at 19:30
    
If this is the correct answer, could you please mark it as such? –  dphil Feb 13 at 19:39
add comment

Your Answer

 
discard

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.