You need to sign in to do that
Don't have an account?
Daniel Mason
Compile Error: Invalid field Materials for SObject Materials_Junction__C
Hi All,
I am hoping you can help me.
This is my Controller, however when i am saving i am getting the the following error message "Error: Compile Error: Invalid field Materials for SObject Materials_Junction__c at line 33 column 17"
i have looked through the relevant examples on wrapper classes however i am a now stuck.
Really appreciated you help
public with sharing class testWrapper { public List<Materials__c> Materials {get;set;} public List<materialWrapper> materialWrapperList {get;set;} public testWrapper() { 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.selectB = 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.selectB == true) { Materials_Junction__c temp = new Materials_Junction__c(); temp.sales_and_marketing__c = '01I20000000rV6V'; temp.Materials= obj.recordIdId; temp.quantity = obj.quantity; } recordToInsert.add(obj); } insert recordToInsert; } public class materialWrapper { public string recordId {get; set;} public string name {get; set;} public string product {get; set;} public string item {get; set;} public Decimal quantity {get; set;} public boolean selectB {get; set;} public void materialWrapper() { recordId = ''; name = ''; product = ''; item = ''; quantity = 0.0; selectB = false; } } }
Materials Object API
Materials Object Fields
Materials_Junction API
Materials_Junction Fields
HI Ram,
I think get the following error "Compile Error: Incompatible element type testWrapper.materialWrapper for collection of Materials_Junction__c at line 36 column 1"
Could you change the below line and try once.
Hi ,
I have made the following edits and i can now save the apex class
Line 36 :
recordToInsert.add(obj);
ToI then changed the following