You need to sign in to do that
Don't have an account?
Priyanka Reddy 74
Im trying to concate id with query but im getting, can some one let me know where i was going wrong.
ERROR: System.QueryException: unexpected token: w00000LEFtiAAH
System.QueryException: unexpected token: w00000LEFtiAAH
for(Schema.FieldSetMember memberObj : SObjectType.Account.FieldSets.rakch__DemoFieldSet.getFields()){ qwerty += ','+memberObj.getFieldPath(); } string id1 = IdList.get(0); string id2 = IdList.get(1); string query1 = qwerty+' from Account where id=' +id1; accList2=Database.query(query1);
Im trying to concate id with query but im getting, can some one let me know where i was going wrong.
ERROR: System.QueryException: unexpected token: w00000LEFtiAAH
To concate the id in your query you have to include the single quotes also. And in dynamic query for single quotes we need the escape character.
string query1 = qwerty+ ' from Account where Id = \'' + id1 + '\'';
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_quotedstringescapes.htm
Thanks,
Maharajan.C
All Answers
To concate the id in your query you have to include the single quotes also. And in dynamic query for single quotes we need the escape character.
string query1 = qwerty+ ' from Account where Id = \'' + id1 + '\'';
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_quotedstringescapes.htm
Thanks,
Maharajan.C