You need to sign in to do that
Don't have an account?
MicheleMcgeoy
Compile Error: expecting right curly bracket,
I am brand new to Apex, so please forgive the basic question, but I am getting the following error from this Apex class: Compile Error: expecting right curly bracket, found 'insert' at line 3
public class CloneClassAttendance {
Campaign NewCamp = new Campaign(Name = 'Test Campaign record');
insert NewCamp;
Campaign NewCamp = [SELECT Type FROM Campaign WHERE Name = 'Test Campaign record'];
NewCamp.Type = 'Class Attendance';
update NewCamp;
}
Any help would be much appreciated.
Thanks, Michele
You must put your logic inside a constructor, method or static block, it's depends you wants.
Then in Execute anonymous window write:
Try it ur missing method:
public class CloneClassAttendance {
public void insertRecord(){
Campaign NewCamp = new Campaign(Name = 'Test Campaign record');
insert NewCamp;
Campaign NewCamp1 = [SELECT Type FROM Campaign WHERE Name = 'Test Campaign record'];
NewCamp.Type = 'Class Attendance';
update NewCamp1;
}
}
Thanks,
Cool Sfdc
This is very helpful. Thanks!
I am now trying to call the code from within a page. I tried pulling the code that you said to execute in anonymous, but that doesn't work. How do I run the code from my page?
<apex:page standardController="Campaign">
CloneClassAttendance myInstance = new CloneClassAttendance();
myInstance.insertRecord();
</apex:page>
Thanks, Michele
Hi MicheleMcgeoy,
Hit KUDOS (Star) if this solution helps you.This will help the rest of the community should they have a similar issue in the future.
Thank you!
Cool Sfdc
Hi Michele,
Yes i find error in your code
1. write code inside Constructore.
2 error in query added colon (:) (Name =:'Test Campaign record')
public class CloneClassAttendance {
public CloneClassAttendance() {
Campaign NewCamp = new Campaign(Name = 'Test Campaign record');
insert NewCamp;
Campaign NewCamp = [SELECT Type FROM Campaign WHERE Name =:'Test Campaign record' limit 1];
NewCamp.Type = 'Class Attendance';
update NewCamp;
}
}
If you face any problem let me know:
Enjoy
Thanks
Satya
This is very helpful. Thanks!
I am now trying to call the code from within a page. I tried pulling the code that you said to execute in anonymous, but that doesn't work. How do I run the code from my page?
<apex:page standardController="Campaign">
CloneClassAttendance myInstance = new CloneClassAttendance();
myInstance.insertRecord();
</apex:page>
Thanks, Michele