You need to sign in to do that
Don't have an account?
icemft1976
APEX variable in SOQL query ( Where ID = :[string] )
I'd like to use an APEX String variable to form the 'where ID =' clause of a SOQL Select statement
I am parsing a salesforce ID out of an email body text then feeding it into this query (which returns no rows):
... String caseNo = email.plainTextBody.substring(email.plainTextBody.indexOf('CaseId:'), email.plainTextBody.indexOf('<caseid>'));
//System.debug(caseNo);
Case caseToUpdate = [ select id, status, subject, description from Case where Id = :caseNo limit 1];
...
Am I misunderstanding the 'ID = ' comparison behavior? When I debug, the runtime variable 'caseNo' is a valid ID.
Any suggestions?
Message Edited by icemft1976 on 05-06-2008 11:29 AM
I am parsing a salesforce ID out of an email body text then feeding it into this query (which returns no rows):
... String caseNo = email.plainTextBody.substring(email.plainTextBody.indexOf('CaseId:'), email.plainTextBody.indexOf('<caseid>'));
//System.debug(caseNo);
Case caseToUpdate = [ select id, status, subject, description from Case where Id = :caseNo limit 1];
...
Am I misunderstanding the 'ID = ' comparison behavior? When I debug, the runtime variable 'caseNo' is a valid ID.
Any suggestions?
Message Edited by icemft1976 on 05-06-2008 11:29 AM
I needed to shift 'right' since I was parsing at the start of my delimiter, not the end...
wrong:
String caseNo = email.plainTextBody.substring(email.plainTextBody.indexOf('CaseId:'), email.plainTextBody.indexOf('<caseid>'));
debug result: caseNo = 'CaseId:50030000004SyXX'
right:
String caseNo = email.plainTextBody.substring(email.plainTextBody.indexOf('CaseId:')+7, email.plainTextBody.indexOf('<caseid>'));
debug result: caseNo = '50030000004SyXX'
the bonus is that it's also much quicker to execute (i think).
Instead of re-inventing the wheel, can you guys point me in the right/better direction?
Thanks.