You need to sign in to do that
Don't have an account?
Siddhant Singh 14
public class TestTriggerss {
for(Opportunity cp:[Select (Select Id from OpportunityContactRoles ), (SELECT product2.name from OpportunityLineItems) from Opportunity where id=0065g000006qGQZAA2])
{
System.debug(cp.ContactId);
System.debug(cp.Pricebook2Id);
}
}
expecting ' }' but was 'for'
public class TestTriggerss {
for(Opportunity cp:[Select (Select Id from OpportunityContactRoles ), (SELECT product2.name from OpportunityLineItems) from Opportunity where id=0065g000006qGQZAA2])
{
System.debug(cp.ContactId);
System.debug(cp.Pricebook2Id);
}
}
You must put your logic inside a constructor, method or static block, it's depends you requirement.
Below code i am writing in constructor.
public class TestTriggerss {
public TestTriggerss(){
for(Opportunity cp:[Select (Select Id from OpportunityContactRoles ), (SELECT product2.name from OpportunityLineItems) from Opportunity where id=0065g000006qGQZAA2])
{
System.debug(cp.ContactId);
System.debug(cp.Pricebook2Id);
}
}
}
All Answers
You must put your logic inside a constructor, method or static block, it's depends you requirement.
Below code i am writing in constructor.
public class TestTriggerss {
public TestTriggerss(){
for(Opportunity cp:[Select (Select Id from OpportunityContactRoles ), (SELECT product2.name from OpportunityLineItems) from Opportunity where id=0065g000006qGQZAA2])
{
System.debug(cp.ContactId);
System.debug(cp.Pricebook2Id);
}
}
}
You Forgot Give Your Class Method Name Please Mark it As Best Answer If It Helps
Thank You!
Hi Siddhant Singh ,
Every logic should be written inside method or constructor,but you haven't done so,that's why you are getting this error:
Here is the solution:
Please Mark it as Best Answer if it helps!
Thanks