function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
satyamsatyam 

Need help to resolve error unexpected token: '{'

Hi,

 

Can anyone please help to resolve the error on below code :

 

 soql ='Select Support_ID__c,Support_Type__c,Customer_Name__c,Supplier_Name__c,Nexeo_Group_Name__c,Supplier_Group_Name__c,'+
          'Effective_Date__c,Expiration_Date__c,Net_Support_Cost__c,Net_Purchase_Cost__c,Requested_Rebate_Amount__c,Status__c,'+
          'Name,Id,Nexeo_Group__c,Submitted_to_Supplier_by__c,Submitted_to_Supplier_Date__c,Supplier_1st_Action_by__c,SAP_Transfer__c,'+
          'Supplier_1st_Action_Date__c,Final_Action_by__c,Final_Action_by_Date__c,Additional_Comments__c,Supplier_Group__c,'+
          'Nexeo_Main_Approver__c,Supplier_Main_Approver__c,Material_Description_Buying__c,Supplier_Supported_Price__c,Packaging_Allowance__c,'+
          'Dis2_Sell__c,Dis1_Sell__c,Freight_Allowance_Selling__c,Other_Allowances__c,New_or_Changed__c,'+
          'Supplier_Sales_Contact__c,Competitor_Name__c,Actual_Annual_Volume__c,Competitor_Manufacturer__c,Application__c,Market_Segment__c,Seller__c '+
          'from Price_Record__c where Status__c=' +'\''+PricerecordUtil.AWAITING_SUPPLIER_APPROVAL +'\' AND (Supplier_Group__c IN '+supplierGroupIds+' OR Supplier_Main_Approver__c='+'\''+UserInfo.getUserId()+'\')';
          if (customerName!=null && !customerName.equals(''))
          soql += 'and CustomerName_Mail__c LIKE \'%'+String.escapeSingleQuotes(customerName)+'%\'';
          
          system.debug(soql);
          supplierApprovalList=Database.query(soql);

 

Error is coming on red line.

 

Thanks in advance:)))

Saikishore Reddy AengareddySaikishore Reddy Aengareddy

Supplier_group__c IN:'+supplierGroupIds

 

Try putting colon(:) after IN... See if it works

satyamsatyam

Thanks for your reply ; i tried its not working.

vishal@forcevishal@force

Hi,

 

For Dynamic SOQL, you have to include the collection inside your string.

 

For example:

 

String soql = 'Select Id, Name From Account Where Name IN : tempSet'

 

Here, tempSet is a Set of String.

 

So, in your code it should be:

 

AND (Supplier_Group__c IN : supplierGroupIds ...)

sfdcfoxsfdcfox

You can build it out manually, but it has to be just right:

 

Supplier_Group__c IN (\''+String.join(new list<string>(suppliergroupids),'\',\'')+'\')

Make sure you're escaping the elements in the set before you do this (soql injection prevention).

 

Edit: Forgot a parens.