You need to sign in to do that
Don't have an account?
Amita Tatar
Save Account survey questions in a child object of Account?
Hi all,
I have a VF page survey form for account which has certain questions. Each account can have multiple survey forms as per services availed.
I want to save these survey forms in a child object of Account.
How i should achieve this part?
Here is my code.
Amita
I have a VF page survey form for account which has certain questions. Each account can have multiple survey forms as per services availed.
I want to save these survey forms in a child object of Account.
How i should achieve this part?
Here is my code.
Class: public with sharing class SurveyClass{ Public Account acc{get;set;} Public List<Proposal_Form__c>pfc; Public Proposal_Form__c pfc1 {get;set;} public ProposalFields__c pf {get;set;} public List<String> fieldSet {get;set;} Public ID rid; public string msg {get;set;} private ApexPages.StandardController standardController; public SurveyClass(ApexPages.StandardController controller) { this.standardController = standardController; pfc1 = new Proposal_Form__c(); } public void Selected(){ system.debug(pfc1.Service_Family__c +'------------'+pfc1.Sub_Service_Category__c); /* try{ pfc = [SELECT Fields_Associated__c FROM Proposal_Form__c where Service_Family__c =: pfc1.Service_Family__c and Sub_Service_Category__c =: pfc1.Sub_Service_Category__c LIMIT 1]; } catch(NullPointerException ex){ Apexpages.addMessage(new ApexPages.Message(ApexPages.SEVERITY.FATAL,'No such combination exists'+ex)); } */ pfc = new List<Proposal_Form__c>(); pfc = [SELECT Fields_Associated__c FROM Proposal_Form__c where Service_Family__c =: pfc1.Service_Family__c and Sub_Service_Category__c =: pfc1.Sub_Service_Category__c LIMIT 1]; if(!pfc.isEmpty()) { fieldSet = new List<String>(); List<String> fields = new List<String>(); if(pfc[0].Fields_Associated__c != null && pfc[0].Fields_Associated__c != ''){ fields = String.valueof(pfc[0].Fields_Associated__c).split(','); system.debug('*********Fields******'+fields); } else{ ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'NO QUESTION SET FOUND')); } Map<String,String> labelMap = new Map<String,String>(); labelMap = getLabel.retLabelMap('ProposalFields__c'); system.debug(labelMap); system.debug(labelMap); for(String s : fields){ fieldSet.add(labelMap.get(s)); system.debug('********fieldset*******'+fieldSet); } } else { ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'NO QUESTION SET FOUND')); } } } VF Page:;; <apex:page standardController="Account" extensions="SurveyClass" sidebar="false" showHeader="false" tabStyle="Account"> <apex:form > <apex:pageMessages rendered="true" id="errMsg" showDetail="false"/> <apex:pageBlock title="Customer Survey Form"> <apex:pageBlockSection title="Service Requirements" > <apex:inputField value="{!pfc1.Service_Family__c}"/> <apex:pageblocksectionItem > <apex:outputLabel value="Sub Service Category"/> <apex:outputPanel > <apex:inputfield value="{!pfc1.Sub_Service_Category__c}"> <apex:actionSupport event="onchange" action="{!Selected}" rerender="fieldst,errMsg" /> </apex:inputField> </apex:outputPanel> </apex:pageblocksectionItem> </apex:pageBlockSection> <apex:pageblockSection title="Question Set" id="fieldst"> <apex:repeat value="{!fieldSet}" var="f"> <apex:inputField value="{!pf[f]}"/> </apex:repeat> </apex:pageblockSection> <apex:pageBlockButtons location="bottom"> <apex:commandButton value="Submit" action="{!save}"/> <apex:commandButton value="Edit" action="{!edit}"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>Thanks,
Amita
PageReference save(){
customobject__c C = new customobject__c ();
C.FieldName__c = FieldName; // map all the object fields with the visualforce input values
insert C; // this will add a new record to customobject in salesforce
return null;
}
Please tell me what i should modify in below code I want to insert question and answers in as multiple records in responsedetail object. How do i achieve it?
Regards,
Amita Tatar