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
Amita TatarAmita Tatar 

save inpufields using custom save in salesfoerce

Hi all,

I have custom save method in my code and two inputfields.
This save functionality is working,but the two inputfields are not getting saved.
I will paste my code here. Please help.Its urgent.

Thanks,
Amita Tatar
class::


public class getLabel{

Proposal_Form__c pfc;
public List<WrapperClass> listWrapper {get;set;}
public Map<String,String> labelMap;
public String resultString {get;set;} 
private ApexPages.StandardController std;

public getLabel(ApexPages.StandardController controller) {
    
    //std = controller;
    pfc = (Proposal_Form__c)controller.getRecord();
    listWrapper = new List<WrapperClass>();
    labelMap = new Map<String,String>();
    labelMap = retLabelMap('ProposalFields__c');
    for(String s : labelMap.values()){
        listWrapper.add(new WrapperClass(s,false));
    }
   
}

public class WrapperClass {  
    public Boolean checkBool {get;set;}
    public String fieldNme{get;set;}  
    public WrapperClass(String prop,Boolean checkBool ){  
        this.fieldNme = prop;  
        this.checkBool = checkBool ;  
    }  
}

public Static Map<String,String> retLabelMap(String type){
    Map<String, Schema.SObjectType> m = Schema.getGlobalDescribe();
    Schema.SObjectType s= m.get(type);
    Map<String, Schema.SObjectField> fieldMap = s.getDescribe().fields.getMap();
    Map<String,String> aMap = new Map<String,String>();
    for (String fieldName: fieldMap.keySet()) {
        aMap.put(fieldName,fieldMap.get(fieldName).getDescribe().getLabel());
    }

    return aMap;
}

public PageReference saveCheckboxValue(){
    List<String> selectedRec = new List<String>();
    if(listWrapper!=null && listWrapper.size()>0){
        for(WrapperClass w : listWrapper){
            if(w.checkBool == true){
              // selectedRec.add(w.fieldNme);
               system.debug('**********'+ selectedRec.add(w.fieldNme));
               resultString = resultString + '  '+ w.fieldNme;
               
        }
       }
    }
     Proposal_Form__c pf = new Proposal_Form__c();
    
     pf.Fields_Associated__c = resultString; 
     insert pf;
   
     PageReference pg = new PageReference('/'+pf.id);
     return pg;
       
     }
 
}


VF



<apex:page showHeader="false" sidebar="false" standardController="Proposal_Form__c" extensions="getLabel">
<apex:form >
<style>
.panelWrapper .mainTitle {
   text-align :center;
    
}
</style>
<apex:outputPanel styleClass="panelWrapper" layout="block">
<apex:pageBlock title="Proposal Form">
<apex:pageBlockSection title="Service Requirements">
<apex:inputField value="{!Proposal_Form__c.Service_Family__c}"/>
<apex:inputField value="{!Proposal_Form__c.Service_Type__c}"/>
<apex:inputField value="{!Proposal_Form__c.Sub_Service_Category__c}"/>

</apex:pageBlockSection>

<apex:pageBlockButtons location="Bottom">
<apex:commandButton value="Save" action="{!saveCheckboxValue}"/>
</apex:pageBlockButtons>

<apex:pageBlockSection title="Available fields">
<apex:repeat var="lab" value="{!listWrapper}">
<apex:pageblockSectionItem >
<apex:outputlabel value="{!lab.fieldNme}"/>
<apex:inputCheckbox value="{!lab.checkBool}"/>
</apex:pageblockSectionItem> 
</apex:repeat>

</apex:pageBlockSection>
</apex:pageBlock>
</apex:outputPanel>

</apex:form> 
</apex:page>

 
Sagar_SFDCSagar_SFDC
Hi Amita,

If your Save Functionality is working then Fields values should be saved in the object field.

Is Your values that you are passing from visualforce going to Controller???

Thanks,
Sagar Sindhi