You need to sign in to do that
Don't have an account?

Compile Error: unexpected token: 'Class' at line 9 column 13
global class MainClass
{
global class RequestClass
{
webservice String errorMessage;
//Account Releated Fields
global Class AccountWrapper // Line9
{
webservice String accName;
webservice Integer accNumber;
webservice Id AccountId;
webservice List<AccountWrapper> accounts;
webservice List<ContactWrapper>;
webservice List<OpportunityWrapper>;
}
//Contact Releated Fields
//webservice String contactName;
global class ContactWrapper
{
webservice String clName;
webservice String cfName;
}
// Opportunity Releated Fields
global class OpportunityWrapper
{
webservice String oName;
webservice String ocDate;
webservice String oStage;
webservice List<ProductWrapper>;
}
// Quote Realeted Fields
webservice String qName;
// Product fields
global class ProductWrapper
{
webservice String productcode;
webservice String productName;
// boolean active;
webservice Integer quantity;
webservice Integer unitprice;
}
// QuoteItem Fields
webservice String qitemName;
}
webservice static ResponseClass behaviourOfWebService(RequestClass req)
{
List<Account> accountList = new List<Account>();
Account a;
for(AccountWrapper wrapper: req.accounts){
a = new Account();
a.Name = wrapper.accName;
a.AccountNumber =String.valueOf(wrapper.accNumber);
accountList.add(a);
}
insert AccountList;
ResponseClass res = new ResponseClass();
res.resId = a.Id;
res.resName = a.Name;
res.cresName = c.FirstName;
// res.respId = p.Id;
return res;
return res;
}
It look like the closing square bracket of MainClass is missing.
Have you tried putting an additional closing square bracket at the very end?
@Wt35
Hi,
i put Square bracket and tried but agin it showing an error.same error,
Check this link, inner classes are only allowed one-level deep:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_defining.htm
It looks like your class at line 9 is two-level deep hence generating the error
Hi..
Try below code...u missed ( } --last line)
Please accept my answer as a solution if my solution was helpful. This will make it available to others as a proper answer. If you felt that I went above and beyond please give me Kudos by clicking on on the star icon.
Thanks,
Cool Sfdc
@Rockz
global class MainClass
{
global class RequestClass
{
webservice String errorMessage;
//Account Releated Fields
global Class AccountWrapper // Error occuring point
{
webservice String accName;
webservice Integer accNumber;
webservice Id AccountId;
webservice List<AccountWrapper> accounts;
webservice List<ContactWrapper>;
webservice List<OpportunityWrapper>;
}
}
global class ResponseClass
{
webservice String resName;
}
webservice static ResponseClass behaviourOfWebService(RequestClass req)
{
List<Account> accountList = new List<Account>();
Account a;
for(AccountWrapper wrapper: req.accounts){
a = new Account();
a.Name = wrapper.accName;
a.AccountNumber =String.valueOf(wrapper.accNumber);
accountList.add(a);
}
insert AccountList;
ResponseClass res = new ResponseClass();
res.resId = a.Id;
res.resName = a.Name;
return res;
return res;
}
}
when i use this code also i am getting same error
Hi,
Update class keyword is small letter.
global Class AccountWrapper
to
global class AccountWrapper
@Sathya_007
HI i do that also but same error is came .
@Satya....
Hope this will help :
change class name...
global Class AccountWrapper
to
global Class AccWrp
Please accept my answer as a solution if my solution was helpful. This will make it available to others as a proper answer. If you felt that I went above and beyond please give me Kudos by clicking on on the star icon.
Thanks,
Cool Sfdc
@Rockz
I tried latest one also but no use same error at same line.
Again, did you ensure that your class is not two-level deep?
You are only allowed to have one-level deep classes...
Please double-check that.