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

Apex Class unexpected token '{'
HI All,
I am hoping you can help me. I am very new to VF and Apex and been using different resources on line and i am now stuck and dont know how to proceed. i am getting the following error 'unexpected token: '{' at line 39 column 26' when trying to save the class
Aim : The user should go to the Sales & Marketing Object, click on a related list, this should then open up a VF page. The VF page should show all of the records from the Materials Object. The user should select the records and the Quanity value, upon save this should then map back to Sales & Marketing Object
I have created the following three objects
Materials = 01I20000000rV5S
Materials Junction = 01I20000000rV6B
Sales and Marketing = 01I20000000rV6V
This is the class that i have produced
public with sharing class test { public List<Materials__c> Materials {get;set;} //global variables public List<materialWrapper> materialWrapperList {get;set;} //use this list on vf page and not Materials //constructor public test() { Materials = [select ID,name,Product__c, Item__c,Quanity__c, Active__c from Materials__c where Active__c =true limit 10]; for(Materials__c obj : Materials){ materialWrapper tempObj= new materialWrapper(); tempObj.recordId = obj.id; tempObj.name = obj.name; tempObj.product = obj.Product__c; tempObj.item = obj.Item__c; tempObj.quantity = obj.Quanity__c; tempObj.select = false; materialWrapperList.add(tempObj); } } //save method public void save() { list<Materials_Junction__c> recordToInsert = new list<Materials_Junction__c>(); for(materialWrapper obj : materialWrapperList){ if(obj.select == true){ Materials_Junction__c temp = new Materials_Junction__c(); temp.sales_and_marketing__c = '01I20000000rV6V'; temp.Materials= obj.recordId; temp.quantity = obj.quantity; } recordToInsert.add(obj); } insert recordToInsert; } public materialWrapper{ string recordId {get; set;} string name {get; set;} string product {get; set;} string item {get; set;} string quantity {get; set;} boolean select {get; set;} public void materialWrapper(){ recordId = ''; name = ''; product = ''; item = ''; quantity = ''; select = false; } } }Materials Junction Fields
Materials Object Fields
Hoping you can help
Looking forward to your response
Many thanks
You missed word "class" on line number 39,
Replace the line 39 with below line and try
"public class materialWrapper"
I hope it works and you will not get error.
Thanks
HI Parmod,
I then get the following error " unexpected token: 'select' at line 45 column 16"
Please try to avoid using Standard keyword. I just updated / Fixed your class. Please try below code
Changes i did
1) Added class keyword in wrapper class
2) Select keyword replace with selectB
3) Updated varaible as public in wrapper class
Let us know if this will help you
"select" is the like keyword so change the name of the variable
eg: isSelect
Thanks
HI Amit and Gowda,
Looks like the main change is on line 58. I forget that that select is a standard sf function. Great spot :)
I do get a new error though Error: Illegal assignment from Decimal to String at line 16 column 13
Why is nothing simple hmpp
Change Line 57 to "quantity = 0.0;"
HI Pramod,
I have made the following changes, however i know get the Invalid field Materials for SObject Materials_Junction__c at line 33 column 17.
If you have a mo can we screen share and try and TS together ?