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

Newbie help on Wrapper Class
Hi fellow Salesforcers
I need some help.
Aim : A user goes to Salesforce and marketing Object , scrolls to related list marketing materials. Click new. This should then opens up a VF page which lists all records in material object.
The User will select what records they want. Upon clicking save, the records chosen should map back to the "Sales and marketing" object
In my developer org i have created the following three objects ;
Sales & marketing
Marketing materials
Material conjuction
Marketing Materials object has the following fields
Product (text)
Item (text)
Active (check box)
Materials conjunction object has the following fields
Master detail to sales and marketing oject
master detail to materials object
I have looked at intro to visual force and I have used the examples and tailored to my needs. To grasp the concept but I am a little confused . I have built this in my own Dev org more than happy to create a new user to walk through this.
Markup
<apex:page controller="test"> <apex:form > <apex:pageBlock title="Select Product"> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save}"/> </apex:pageBlockButtons> <apex:pageBlockTable value="{!Materials}" var="MKT"> <!-- for loop of contact in Materials --> <apex:column value="{!MKT.name}"/> <apex:column value="{!MKT.Product__c}"/> <apex:column value="{!MKT.Item__c}"/> <apex:column value="{!MKT.Quanity__c}"/> <apex:column value="{!MKT.Active__c}"/> <apex:column headerValue="Quanity"> <apex:inputField value="{!MKT.Quanity__c}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>Controller
public with sharing class test { public List<Materials__c> Materials {get;set;} //global variables //constructor public test() { Materials = [select ID,name,Product__c, Item__c,Quanity__c, Active__c from Materials__c where Active__c =true limit 10]; } //save method public void save() { update Materials; } }This is the current outcome, however as you can see when i save its just update quantity value on the materials object
Looking forward to your response
Regards
Masond3
Wrapper classes
Public class wrapperClassName {
public string fieldName1 {get;set;}
public string fieldName2 {get;set;}
}
Use….
Public wrapperClassName {get;set;}
…...
wrapperClassName = new wrapperClassName();
wrapperClassName.fieldName1 = ‘Value1’;
wrapperClassName.fieldName2 = ‘Value 2’;
Just for clarification, whatever user will select from Marketing materials which would be coming as list on visualforce page should be saved in "Material conjuction" and should be visible under "Sales & marketing" as related list. Also quantity selected should create that many records of material selected or should just update a field on "Material conjuction" to show how many quantities are needed?
Hello Swati,
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
You need to use wrapper class and your code should be something like: