0

Is there anything wrong in this dynamic query.

I am trying to fetch child records(contacts) for all those accounts whose recordtype is 'Recordtype1'

string sobjectParent, 
relationName, 
fieldChild,
contactRT;
sobjectparent = 'Account';
relationName = 'Contacts';
fieldchild = 'LastName';
contactRT = 'Recordtype1';
string soqlParent = 'select id, (select '+fieldChild +' from '+relationName +') from '+sobjectParent +'where RecordType.Name=:contactRT';

database.query(soqlparent);

I get this exception invalid alias recordtype.name

1 Answer 1

1

You're missing a space between sobjectparent and where. Change 'where to ' where.

1
  • I was staring at this for past 10-15mins ...you rock..it worked:)
    – sfdc99999
    Jul 3, 2014 at 16:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .