0

I have a Visualforce page with picklist and associated fields with it. When the picklist value is no I want the other input field values that we have provided to be saved in the database after clicking save button. other than no any other value we give it should be removed from database.

  if(ds.Yes_No__c=='No')
                {
                ds.Responsible_Person_TEXT__c = sw.dc.Responsible_Person_Text__c;
                ds.Responsible_Person__c = sw.dc.Responsible_Person_Text__c;
                ds.Target_Completion_Date__c =sw.dc.Target_Completion_Date__c;
                ds.Action_Plan__c=sw.dc.Action_Plan__c;
                }
                else
                {
                ds.Responsible_Person_TEXT__c = '';
                ds.Responsible_Person__c = '';
                ds.Target_Completion_Date__c =null;
                ds.Action_Plan__c='';
                }
   dsSet.add(ds);

           //} 
        }
        dslist.addall(dsSet);
        try{
            if(dsList.size()>0){
            System.debug('ds.iddddddd>>>>'+dsList.size());
                upsert dslist Dealer_External_Id__c;
            }
         //return null;
        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'All Standards have been Saved Successfully'));
        }catch(exception e){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Couldn\'t Save Standards, PLease try again'));
        }

This method returns:

 PageReference RetPage = ApexPages.currentPage();
          RetPage.setRedirect(true);
       //return RetPage; 
          return null;

This is the button for save

 <apex:commandButton value="Save Standards" onclick="showSucMsg(); return false; window.top.location.reload();" styleclass="cust-btn"/>

                <apex:actionFunction action="{!saveSS}" name="saveSS"/>//here it calls the above methods of class

Its updating the value only after page refresh, but I want it to be retrieved from db once after the button is clicked

Need suggestions,

1
  • Could you please post the complete code for your page and controller. From the pieces your provided it's not clear in which order your code executes. For example, I don't see what code calls the "saveSS" function on your page. Moreover, there is no saveSS method in your controller example. Would you please make it more coherent?
    – Eduard
    Commented Jul 11, 2018 at 10:11

1 Answer 1

1

If you don't want the whole page refreshed after the user clicks on the "Save Standards" button, you need:

  1. Use a ReRender attribute on you AJAX caller (apex:actionFunction in your case) and specify a component on the page you want to refresh after the AJAX call completes.

  2. Also the apex:commandButton has this code "window.top.location.reload();" on the click event. Remove it

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .