+ Start a Discussion
AnjaneyluAnjaneylu 

unable to bind input field values to controller extension.

Hi All,

Here i am unable to handle/bind the value from vf page Input field to controller extension. While saving the record it is havaing the value as null for picklist fields..Can you help me on this. I want to save the values what i entered/selected on UI.
 
<apex:page standardcontroller="Account" extensions="QuickActionToCreateCaseExtension" showHeader="false" doctype="html-5.0" lightningStylesheets="true"> 
   <apex:slds />

    
    
        <apex:form id="FormID">
            <apex:actionFunction action="{!createCase}" name="createCase" rerender="FormID,out"  oncomplete="window.opener.location.refresh();"/> 
            <apex:outputPanel id="out">
                <table >
                    <tbody>
                        <tr>
                            <td class = "labelCol">
                                <label>Type: &nbsp; &nbsp;</label>
                            </td>
                            <td>  <apex:inputfield value="{!theCase.type}" id="TypeID"/> </td>
                            
                        </tr>
                        <tr>
                            <td class = "labelCol" id="subtabid">
                                <label>Sub Type: &nbsp; &nbsp;</label>
                            </td>
                            <td>
                              <apex:inputfield value="{!theCase.Sub_Type__c}" onchange="CaseSubTypeChange();" id="SubtypeID"/>
                            </td>
                        </tr>
                        <tr id="AssetID">
                            <td class = "labelCol">
                                <label>Serial Number : &nbsp; &nbsp;</label>
                            </td>
                            <td> </td>
                        </tr> 
                         <tr id="ReplcmntSerId">
                            <td class = "labelCol">
                                <label>Replacement Serial Number : &nbsp; &nbsp;</label>
                            </td>
                            <td> <apex:inputField value="{!theCase.Replacement_Serial_Number__c}"> </apex:inputField>  </td>
                        </tr>
                        <tr id="DescrID">
                            <td class = "labelCol">
                                <label>Description : &nbsp; &nbsp;</label>
                            </td>
                            <td> <a data-toggle="tooltip" title="If you selected 'Partial Solution' or 'Component', then please provide the following:
						Target Solution (Root Asset Id):
							Asset Ids (SFDC Ids - Bundle = Level 2, Component = Level 3):"><apex:inputField value="{!theCase.Description}" id="DESId" > </apex:inputField>  </a></td>
                        </tr>
                           
                        <tr id="DestnSiteID">
                            <td class = "labelCol">
                                <label>Destination Site : &nbsp; &nbsp;</label>
                            </td>
                            <td> <apex:inputField value="{!theCase.Destination_Site__c}"> </apex:inputField>  </td>
                        </tr>
                        <tr id="AssetMoveID">
                            <td class = "labelCol">
                                <label>Asset Move Type : &nbsp; &nbsp;</label>
                            </td>
                            <td> <apex:inputField value="{!theCase.Asset_Move_Type__c}"> </apex:inputField>  </td>
                        </tr>
                        <tr id="OrderID">
                            <td class = "labelCol">
                                <label>Order : &nbsp; &nbsp;</label>
                            </td>
                            <td> <apex:inputField value="{!theCase.Order__c}"> </apex:inputField>  </td>
                        </tr> 
                        <tr>
                            <td align= "Center">
                                <button type="button" 
                                        style="position:fixed;padding:5px 10px; font-size:13px; font-weight:bold; line-height:18px;" onclick = "createCase()" id="addcasebutton">Create Case</button> 
                            </td>
                        </tr>
                    </tbody>
                </table>
            </apex:outputPanel>
        </apex:form>
    

    
</apex:page>
 
public class QuickActionToCreateIBATCaseExtension {
    private final SObject parent;
    public Case theCase {get; set;}
	//public Case theFinalCase {get; set;}

    public String lastError {get; set;}
    
    public account acc {get; set;}
    Id ITRecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('IT').getRecordTypeId();
    
    public QuickActionToCreateCaseExtension (apexpages.StandardController controller){
        parent = controller.getRecord();
        acc = [select id,name, Geo2__c from account where id =:parent.id ];
        theCase = new Case();
        //theFinalCase = new Case();
		theCase.recordtypeId = IBATRecordTypeId ;

        lastError = '';
    }
    public PageReference createCase() {
		theCase = new Case();

        theCase.origin = 'Internal';
       // theCase.Subject =  +theCase.Destination_Site__c;
        theCase.accountId = parent.id;
        theCase.MDMGeo__c = acc.Geo2__c;
        theCase.Priority = '1-High';
       	/*theCase.type = +theCase.Type;
        theCase.Sub_Type__c = +theCase.Sub_Type__c; */
        theCase.recordtypeid = ibRecordTypeId ;
        theCase.Subject = acc.name+ '| ' +theCase.Destination_Site__c;         

        createNewCase();

        return null;
    }
    private void createNewCase() {      
        try {
            /*Database.DMLOptions dml = new Database.DMLOptions(); 
            dml.DuplicateRuleHeader.AllowSave = true;
            //Account duplicateAccount = new Account(Name='dupe');
            Database.SaveResult sr = Database.insert(theCase, dml);*/
            insert theCase;
            //
           // if(sr.isSuccess()){
               // System.debug('Case inserted successfully and id is --'+sr.getId());
                FeedItem post = new FeedItem();
                post.ParentId = ApexPages.currentPage().getParameters().get('id');
                post.Body = 'IBAT case created';
                post.type = 'LinkPost'; 
                post.LinkUrl = '/' + theCase.Id;
                post.Title = theCase.Subject;
                insert post;
                
           /* }
            else{
                System.debug('errors are---'+sr.getErrors());
            }*/
            
            
            
        } catch(System.Exception ex){
            lastError = ex.getMessage();
            system.debug('ThelastError  '+lastError);
            
        }
    }   
    
    
}

Your inputs much appreciated. 

Thanks in advance,