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
maiyakumaiyaku 

Error Deployment

Failure Message: "System.QueryException: unexpected token: '('", Failure Stack Trace: "Class.BDAPP.QueryRelationShip: line 173, column 1 Class.BDAPP.RunBDAPP: line 63, column 1 Class.BDAPP.execute: line 21, column 1"

 

Start Line 163 and End Line 173

 

WhereCondition = 'ID In(' + RelationshipQueRy + ')';
        
            Query  = 'Select ID, Contact_ID__c, Account_ID__c, Rev_Contact_ID__c,Rev_Account_ID__c,Rev_Account_ID__r.Loyalty__c,Rev_Account_ID__r.CustomerPriority__c,Rev_Contact_ID__r.Account_Number__c,Rev_Account_ID__r.List_Office__c, ';
            Query += 'Contact_ID__r.name, Rev_Contact_ID__r.name, Account_ID__r.name, Rev_Account_ID__r.Name,Rev_Account_ID__r.BP_Type__c,Position__c,Relationship_Category__r.name,Rev_Contact_ID__r.AccountMarkDelStatus__c, ';
            Query += 'Position_Group__c,Contact_ID__r.AccountId,Rev_Account_ID__r.AccountNumber,Contact_ID__r.Phone,Contact_ID__r.MobilePhone,Relationship_Category__r.Relation_to_Owner_TH__c,Rev_Account_ID__r.List_Sales_Rep__c,Rev_Account_ID__r.List_District__c, ';
            Query += 'Contact_ID__r.Sex__c,Rev_Contact_ID__r.Sex__c,Relationship_Category__r.Reverse_Relationship_Category__r.name,Rev_Contact_ID__r.AccountID,Rev_Contact_ID__r.Account_Name__c,Rev_Account_ID__r.Mark_for_Delete__c ';
            Query += 'FROM Relationship__c ';
            Query += 'Where ' + WhereCondition;

            
        List<sObject> SRelation = Database.Query(Query);

 

Thank you so much.


MandyKoolMandyKool

Hi,

 

Whether the same code works in sandbox?

 

If possible you can use the System.debug() statement to print your entire query. So that you will get to know if query is generated properly. Looks like while generating the query there is an addition '('.

maiyakumaiyaku

It work in sendbox not error when run test but failed when inbound in production .

I try add system.debug but it error .

String WhereCondition = '';
        
        //WhereCondition = 'ID In(' + RelationshipQueRy + ')';
        
            Query  = 'Select ID, Contact_ID__c, Account_ID__c, Rev_Contact_ID__c,Rev_Account_ID__c,Rev_Account_ID__r.Loyalty__c,Rev_Account_ID__r.CustomerPriority__c,Rev_Contact_ID__r.Account_Number__c, ';
            Query += 'Contact_ID__r.name, Rev_Contact_ID__r.name, Account_ID__r.name, Rev_Account_ID__r.Name,Rev_Account_ID__r.BP_Type__c,Position__c,Relationship_Category__r.name,Rev_Contact_ID__r.AccountMarkDelStatus__c, ';
            Query += 'Position_Group__c,Contact_ID__r.AccountId,Rev_Account_ID__r.AccountNumber,Contact_ID__r.Phone,Contact_ID__r.MobilePhone,Relationship_Category__r.Relation_to_Owner_TH__c,Rev_Account_ID__r.List_Sales_Rep__c, ';
            Query += 'Contact_ID__r.Sex__c,Rev_Contact_ID__r.Sex__c,Relationship_Category__r.Reverse_Relationship_Category__r.name,Rev_Contact_ID__r.AccountID,Rev_Contact_ID__r.Account_Name__c,Rev_Account_ID__r.Mark_for_Delete__c ';
            Query += 'FROM Relationship__c ';
            Query += 'Where ID In(' + RelationshipQueRy + ')';
            
        system.debug('###########QUERY : ' + query);    
            
        List<sObject> SRelation = Database.Query(Query);

 Thank you.