+ Start a Discussion
Christopher PezzaChristopher Pezza 

Can't Perform save Function in Apex

So i'm trying to save a record on a visual force page but it won't perform the save function. It gets into the method but never actually grabs the information from the page. NAy Ideas? Here is my Code

public with sharing class nCino_CustomerHealthIndividual{

      public string CHidNum = Apexpages.currentPage().getParameters().get('id');
      public Customer_Health__c CustomerHealth {get;set;}

      public nCino_CustomerHealthIndividual(){
            this.CustomerHealth = getCustHealth();

     public PageReference save() {
        update this.CustomerHealth;
        return null;

    //Customer Health Fields
    public List<Schema.FieldSetMember> getCHFields() {
        return SObjectType.Customer_Health__c.FieldSets.Main.getFields();

    public Customer_Health__c getCustHealth() {
        String query = 'SELECT ';
        for(Schema.FieldSetMember f : this.getCHFields()) {
            query += f.getFieldPath() + ', ';
        query += 'Id, Name FROM Customer_Health__c WHERE Id = :CHidNum LIMIT 1';
        return Database.query(query);

<!-- Edit System Information -->
                <div class="modal modal-flex fade" id="editsysteminfomodal" tabindex="-1" role="dialog" aria-labelledby="editsysteminfomodallabel" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                    <h4 class="modal-title" id="editsysteminfomodallabel">Edit System Information Section</h4>
                            <div class="modal-body">
                                <form class="form-horizontal" role="form">
                                    <div class="form-group">
                                        <label class=" col-md-5 control-label">nCino Sandbox Version</label>
                                        <div class="col-md-7">
                                            <apex:inputField value="{!CustomerHealth.Sandbox_Version__c}"/>
                            <div class="modal-footer">
                                <apex:commandButton value="Save" action="{!save}"></apex:commandButton>
                        </div> <!-- /.modal-content -->
                    </div> <!-- /.modal-dialog -->
                </div> <!-- /.modal -->

James LoghryJames Loghry
Sounds like your update call is throwing an exception.  Try printing this out by
  1. Adding a rerender="editsysteminfomodal"
  2. Adding an <apex:pageMessages /> tag somewhere inside the modal div.

The apex:pageMessages should print out a informational message to help you fix your issue.  You could also add debug logs to your save method as well. 
Christopher PezzaChristopher Pezza
OK i added those two items and still nothing. Added the debug statements and it looks like it is not grabbing the information changed. I chaged the value in the modal and i changed it but still grabbed the original value to save. It is entering the function. Any Ideas?
Gooch ForeverGooch Forever
Hi Chrostopher

Change the Save() method name to some other name and call from Save button in VF page. There is the possibility of contradiction in standard method name Save().
Christopher PezzaChristopher Pezza
Changed the name and that didn't work either