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

Passing fieldset value into apex class
My Vf Page:
I want to pass the Input Field of type picklist to apex Class which i am displaying in Vf page using fieldset.I am not able to get the value in the apex class.where Am i going Wrong?
<apex:page standardcontroller="Program_Member_MVN__c" extensions="ProgramMemberCaseAttachment" showHeader="false" > <head> <apex:includeScript value="/support/console/40.0/integration.js"/> <apex:includescript value="/soap/ajax/33.0/connection.js"/> <apex:includescript value="/soap/ajax/33.0/apex.js"/> <apex:includescript value="//code.jquery.com/jquery-1.11.1.min.js"/> <apex:includescript value="//cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js"/> <apex:stylesheet value="//cdn.datatables.net/1.10.4/css/jquery.dataTables.css"/> <script type="text/javascript"> j$ = jQuery.noConflict(); j$(document).ready( function () { var contactTable = j$('[id$="accounttable"]').DataTable({ }); }); <!-- var Type = '{!AttType}'; const selectEl = document.getElementById('{!$Component.newPageBlock.Section.DateRange}');--> function Callmefunc() { alert(document.getElementById('{!$Component.form.newPageBlock.Section.DateRange}')); if(document.getElementById('{!$Component.form.newPageBlock.Section.DateRange}') == 'None') { alert('Select a Type'); } } </script> </head> <apex:form id="form"> <!--<apex:pageMessages id="showmsg"></apex:pageMessages>--> <apex:pageBlock id="newPageBlock"> <apex:pageBlockSection title="Input Type" columns="3" > <apex:outputLabel ></apex:outputLabel> <apex:repeat value="{!fields}" var="f"> <apex:inputField value="{!docList[f.fieldPath]}" label="Select Input Type (then click save) =>"/> </apex:repeat> </apex:pageBlockSection> <apex:pageBlockSection columns="3" id="Section"> <!--<apex:outputLabel ></apex:outputLabel> <apex:outputLabel style="font-weight:bold"><p1>Select Input Type (then click save) =></p1> <apex:selectList id="DateRange" value="{!AttType}" size="0" style="background-color:{!(IF(AttType!=null,'red','white'))}"> <apex:actionSupport event="onchange" action="{!processSelected1}"/> <apex:selectOption itemValue="None" itemLabel="None"/> <apex:selectOption itemValue="Chart Notes" itemLabel="Chart Notes"/> <apex:selectOption itemValue="Consent" itemLabel="Consent"/> <apex:selectOption itemValue="Insurance Communication" itemLabel="Insurance Communication"/> <apex:selectOption itemValue="MDO Communication" itemLabel="MDO Communication"/> <apex:selectOption itemValue="PA Form" itemLabel="PA Form"/> <apex:selectOption itemValue="Patient Communication" itemLabel="Patient Communication"/> <apex:selectOption itemValue="SRF Incomplete" itemLabel="SRF Incomplete"/> <apex:selectOption itemValue="SRF PFS" itemLabel="SRF PFS"/> <apex:selectOption itemValue="SRF Rebidose" itemLabel="SRF Rebidose"/> <apex:selectOption itemValue="SRF Sample" itemLabel="SRF Sample"/> </apex:selectList> </apex:outputLabel>--> <!--<apex:outputText value="{!callfunc}" escape="false"></apex:outputText>--> </apex:pageBlockSection> <apex:pageBlockTable id="accounttable" value="{!PMresults}" var="N" columnClasses="display"> <apex:column headerValue="Save"> <apex:commandLink value="Save" action="{!processSelected}" oncomplete="window.location.href='/apex/ProgramMemberCaseAttachment?id={!Program_Member_MVN__c.id}'; return false"> <apex:param name="{!N.Attachment_Id__c}" value="{!N.Attachment_Id__c}" assignTo="{!Attid}"/> </apex:commandLink> </apex:column> <!--<apex:column headerValue="Attachment Name"> <apex:outputField value="{!N.Attachment_Name__c}"/> </apex:column>--> <apex:column headerValue="Attachment"> <apex:outputField value="{!N.Attachment__c}"/> </apex:column> <apex:column headerValue="Type"> <apex:outputField value="{!N.Type__c}"/> </apex:column> <apex:column headerValue="PM Number"> <apex:outputLink value="/{!N.Program_Member_Lookup__c}" target="_blank">{!N.Program_Member_Lookup__r.Name}</apex:outputLink> </apex:column> <apex:column headerValue="Case Number"> <apex:outputLink value="/{!N.Case_Lookup__c}" target="_blank">{!N.Case_Lookup__r.Casenumber}</apex:outputLink> </apex:column> <apex:column headerValue="Created Date"> <apex:outputField value="{!N.Created_Date__c}"/> </apex:column> <!--<apex:column headerValue="Name"> <apex:outputLink value="/{!N.Id}" target="_blank">{!N.Name}</apex:outputLink> </apex:column>--> <apex:column headerValue="Description"> <apex:outputField value="{!N.Attachment_Description__c}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>Apex Class:
/** * ProgramMemberCaseAttachment * Created By: Varun * Created On: 11/07/2017 * Description: This class is responsible for displaying Attachment Details Under Each Program Member * **/ public with sharing class ProgramMemberCaseAttachment{ public Attachment_Type__c docList{get; set;} public string callfunc{get;set;} public string AttType{get;set;} public Id Attid{get;set;} public List<Attachment_Type__c> PMresults{get;set;} public Program_Member_MVN__c cs; public ProgramMemberCaseAttachment(ApexPages.StandardController controller) { //AttType =''; cs=(Program_Member_MVN__c)controller.getRecord(); List<case> Test = new List<case>([select id from case where Program_Member_MVN__c =: cs.id]); System.debug('Test:'+Test); List<String> Id = new List<String>(); System.debug('AttType:'+AttType); for(case Cs1 : Test){ Id.add(Cs1.id); } PMresults = [select Created_Date__c,Program_Member_Lookup__r.Name,Case_Lookup__r.Casenumber,Attachment__c,Case_Lookup__c,Program_Member_Lookup__c,Attachment_Id__c,Parent_Id__c,Id,Attachment_Name__c,Attachment_Description__c,Name,Type__c from Attachment_Type__c where Program_Member_Lookup__c =: cs.id OR Case_Lookup__c IN: Id]; System.debug('PMresults '+PMresults ); } public List<Schema.FieldSetMember> getFields() { return SObjectType.Attachment_Type__c.FieldSets.Attachment_Type.getFields(); } public void processSelected1(){ //AttType = System.currentPageReference().getParameters().get('Test'); System.debug('AttType'+AttType); } public void processSelected(){ String strList = String.valueOf(docList); System.debug('AttType 1'+AttType); System.debug('AttType 2'+docList); List<Attachment_Type__c> PMType = new List<Attachment_Type__c>(); Attachment_Type__c At1 = new Attachment_Type__c (); At1 = [select Type__c from Attachment_Type__c where Attachment_Id__c =: Attid]; System.debug('At1 '+At1 ); if(strList == 'None'){ //pagereference p = apexpages.Currentpage(); //ApexPages.Message myMsg = new ApexPages.Message(ApexPages.severity.FATAL,'You can not choose none'); //ApexPages.addMessage(myMsg); //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'You can not choose none')); //callfunc = '<script> Callmefunc(); </script>'; } else{ At1.Type__c = strList; PMType.add(At1); } set<Attachment_Type__c> dedupSet = new set<Attachment_Type__c>(); dedupSet.addAll(PMType); List<Attachment_Type__c> dedupList = new List<Attachment_Type__c>(); dedupList.addAll(dedupSet); System.debug('dedupList'+dedupList); Update dedupList; } }
I want to pass the Input Field of type picklist to apex Class which i am displaying in Vf page using fieldset.I am not able to get the value in the apex class.where Am i going Wrong?
Please give this a try