function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Daniel MasonDaniel Mason 

Visual force page not displaying correct output.

Good afternoon,
I am hoping you can help me.
I am building a POC and i have hit a brick wall and really appreciate some help form the community.

Problems :
My visual force page doesnt show a tick box. When i push save, i dont see the record being mapped back anywhere. when on Materials_Junction object and look at Buttons, Links, and Actions i edit the "new" button to add the visual force page, however no vf pages are presented.

Ideal Solution :
Go to the sales & marketing object, scroll to the "Materials_Junction" related list and click on "New". Upon clicking on "New" it should open up the "visual force" page below (which references the "materials" object). The user should select the "material" via a tick box add a quantity,upon clicking the save button on the visual force page, the values the user has selected should get mapped back to the "sales & marketing object"
Apex Controller

Apex controller 
public with sharing class testWrapper
    public List<Materials__c> Materials {get;set;} 
    public List<materialWrapper> materialWrapperList {get;set;} 
    public testWrapper()
        materialWrapperList = new List<materialWrapper>();
        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 =;
            tempObj.product = obj.Product__c;
            tempObj.item = obj.Item__c;
            tempObj.quantity = obj.Quanity__c;
            tempObj.selectB = false;

    //save method
    public void save()
        list<Materials_Junction__c> recordToInsert = new list<Materials_Junction__c>();
        for(materialWrapper obj : materialWrapperList)
         Materials_Junction__c temp ;
            if(obj.selectB == true)
                temp = new Materials_Junction__c();
                temp.sales_and_marketing__c = 'a032000000VQaRT';
                temp.Materials__C= obj.recordId;
                temp.quantity__C = obj.quantity; 
            //recordToInsert.add(temp); you are adding element outside the if condition that the reason for save button error
        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;

visual force page 
<apex:page controller="testWrapper">
    <apex:form >
        <apex:pageBlock title="Select Product">

            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>

            <apex:pageBlockTable value="{!materialWrapperList}" var="MKT"> <!-- for loop of contact in Materials -->
                <apex:column value="{!MKT.selectB}"/>
                <apex:column value="{!}"/>       
                <apex:column value="{!MKT.Product}"/>
                <apex:column value="{!MKT.Item}"/>
                <apex:column headerValue="Quantity">
                    <apex:inputText value="{!MKT.quantity}"/>



Really appreciate all the help i can get 
Hi Daniel,

The reason why it is not showing the checkbox field is because you didn't added the

<apex:inputCheckbox value="{!selectB}" /> in your pageBlockTable.

and also not you need to declare selectB as public get; set; property.

Pls mark this answer if it resolves this your query.

Dilip Singh
If you want to override the standard New button then you have to use the standard controller of that object in your vf page.