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
SriniSrini 

Error:line breaks not allowed in string literals

Hi Team,

When we are using Below SOQL we are facing Erro Like "the line breaks not allowed in string literals"

SOQL:

Public String query = 'SELECT id,name,Opportunity.RecordType.name,
       (SELECT Id,Ownerid, ActivityDate FROM OpenActivities Order By LastModifiedDate ASC),(SELECT LastModifiedDate,TeamMemberRole FROM OpportunityTeamMembers WHERE TeamMemberRole = \'Team\'') From Opportunity where id =  'OptyID';

How to remove the litterals from above query.Please Help us

Thanks
Ashwani PradhanAshwani Pradhan
Use this line with removed line break and applied rquired quotes -
Public String query = 'SELECT id,name,Opportunity.RecordType.name,(SELECT Id,Ownerid, ActivityDate FROM OpenActivities Order By LastModifiedDate ASC),(SELECT LastModifiedDate,TeamMemberRole FROM OpportunityTeamMembers WHERE TeamMemberRole = \'Team\') From Opportunity where id =  \'OptyID\'';

 
Vishal_GuptaVishal_Gupta
Hi Srini,

Please try below code :
 
Public String query1 = 'SELECT id,name,Opportunity.RecordType.name,(SELECT Id,Ownerid, ActivityDate FROM OpenActivities Order By LastModifiedDate ASC),(SELECT LastModifiedDate,TeamMemberRole FROM OpportunityTeamMembers WHERE TeamMemberRole = \'Team\') From Opportunity where id =  \''+OptyID+'\'';

Let me know if still receive the same error.

Thanks,
Vishal
SriniSrini
Hi Vishal,

Thanks for your help.Query is working fine but When we are excuting in Anonymous class we are getting error like "Loop variable must be an SObject or list of Opportunity".

Can you please help me on this issue.

Thanks