more-arw search

Q&A Forum

Error MessageSystem.QueryException: unexpected token: '('

Saanvi Sharma's Profile

Please could someone help me
Error MessageSystem.QueryException: unexpected token: '('
Stack TraceClass.batchAccountUpdate.start: line 4, column 1

I get this error message when I am trying to run the test class for this batch

01 global class batchAccountUpdate implements Database.Batchable {

02 global Database.QueryLocator start(Database.BatchableContext BC) {

03 String query = 'SELECT id, Name FROM Opportunity WHERE Createddate =:system.today() AND Status <> \'closed\' AND Has_IBM_Product__c = False AND Id IN : (SELECT OpportunityId FROM OpportunityLineItem WHERE pricebookentry.product2.family =\'XYZ\') limit 10';

04

05 return Database.getQueryLocator(query);

06 }

07

08 global void execute(Database.BatchableContext BC, List scope) {

09 for(Opportunity Opp : scope)

10 {

11 Opp.Has_ABC_Product__c = True;

12 }

13 update scope;

14 }

15

16 global void finish(Database.BatchableContext BC) {

17 }

18
}

Thank in Advance
Saanvi S
https://mindmajix.com/salesforce-admin-training

Answers

Topic Expert
Len Green
Title: Performance Improvement Consultant and E..
Company: Haygarth Consulting LLC
LinkedIn Profile
(Performance Improvement Consultant and ERP Strategist, Haygarth Consulting LLC) |

I think you may find better answers from a Developer community than this one, which is for finance and accounting people - i.e. end users of technology.

Topic Expert
Wayne Spivak
Title: President & CFO
Company: SBAConsulting.com
LinkedIn Profile
(President & CFO, SBAConsulting.com) |

While not an expert and Len's answer is 100% correct try this:

You wrote:
03 String query = 'SELECT id, Name FROM Opportunity WHERE Createddate =:system.today() AND Status <> \'closed\' AND Has_IBM_Product__c = False AND Id IN : (SELECT OpportunityId FROM OpportunityLineItem WHERE pricebookentry.product2.family =\'XYZ\') limit 10';

I'd try:

03 String query = 'SELECT id, Name FROM Opportunity WHERE Createddate =:system.today() AND Status <> 'closed' AND Has_IBM_Product__c = False AND Id IN : SELECT OpportunityId FROM OpportunityLineItem WHERE pricebookentry.product2.family ='XYZ' limit 10';

Not sure about the ":" after ...id IN, but you get the idea.

854 views
Topics

Get Free Membership

By signing up, you will receive emails from Proformative regarding Proformative programs, events, community news and activity. You can withdraw your consent at any time. Contact Us.

Business Exchange

Browse the Business Exchange to find information, resources and peer reviews to help you select the right solution for your business.

Learn more

Contribute to Community

If you’re interested in learning more about contributing to your Proformative community, we have many ways for you to get involved. Please email content@proformative.com to learn more about becoming a speaker or contributing to the blogs/Q&A Forum.