You need to sign in to do that
Don't have an account?
Vandana Rattan
Query to Fetch OpportunityLineItems
I am writing a scheduler to run a batch process monthly on OpportunityLineItems and update the ServiceDate to Current Date. The query that I am usin to fetch OpportunityLineItems for Opportunities whose CloseDate > Today's date gives error.
Query:-
'SELECT servicedate, opportunityid from OpportunityLineItem where opportunityid IN \'(SELECT id from opportunity where closeDate >\')' + System.today().format();
Error:
00:00:22.058 (58548104)|EXCEPTION_THROWN|[11]|System.QueryException: expecting a colon, found '(SELECT id from opportunity where closeDate >'
00:00:22.058 (58619737)|SYSTEM_METHOD_EXIT|[11]|Database.getQueryLocator(String)
00:00:22.058 (58676089)|FATAL_ERROR|System.QueryException: expecting a colon, found '(SELECT id from opportunity where closeDate >'
How should I modify the query?
Thanks in Advance!
Query:-
'SELECT servicedate, opportunityid from OpportunityLineItem where opportunityid IN \'(SELECT id from opportunity where closeDate >\')' + System.today().format();
Error:
00:00:22.058 (58548104)|EXCEPTION_THROWN|[11]|System.QueryException: expecting a colon, found '(SELECT id from opportunity where closeDate >'
00:00:22.058 (58619737)|SYSTEM_METHOD_EXIT|[11]|Database.getQueryLocator(String)
00:00:22.058 (58676089)|FATAL_ERROR|System.QueryException: expecting a colon, found '(SELECT id from opportunity where closeDate >'
How should I modify the query?
Thanks in Advance!
Use below code
If it helps you than plese mark it as a solution
All Answers
Use below code
If it helps you than plese mark it as a solution