I am new to salesforce and working on a sample project. My VF page looks like the below image.enter image description here The page has 2 outputpanels, leftOPanel and rightOPanel. The rightOPanel has inputfields,save and cancel button.

After the save action, I reset the controls using javascript as rerenering support is not available for rich text. The Save feature works fine and rerenders the leftOPanel. The problem is when I try to delete a record in the leftOPanel. I delete a record using a remote function and refresh the leftOPanel using an action function. The delete actually deletes a record but the rerendering shows the deleted record also after the rerender. The log is showing the below errors.enter image description here

It deletes and rerenders the page without any issues, only when I select some value in the Platform field(a mandatory field in the object) and press the delete button. This is not the wanted functionality. When the user want to delete a record, he would just click the delete button, wouldn't want to select some random value in a picklist before hitting the delete button. I don't understand why the validation error occurs, because I don't see that error message in the screen. why this error message in rightOPanel matters when I try to update my LeftOPanel? Please advise.

<apex:commandbutton styleclass="slds-button" value="Delete" onclick="DeleteProject('{!p.Name}');return false;" />

Code for action function

<apex:actionFunction name="rerenderleftOPanel"  action="{!initProjList}" rerender="leftOPanel" />

Javascript code


            var j$=jQuery.noConflict();
            function ResetControls(){
                j$("[title^='Rich Text Editor']").contents().find('body').html('');
            function DeleteProject(projId)
                        if (event.status){
                    }, {escape:true}

Controller code

global with sharing class ProjectController {

public  List<Project__c> lstproj{get; set;}
public Project__c prj{get; set;}

public ProjectController(ApexPages.StandardController controller)
    prj = new Project__c();
    lstproj = [SELECT Name,Proj_Name__c,Status__c,Abstract__c
               FROM Project__c ];

public PageReference save()
    insert prj;        
    lstproj = [SELECT Name,Proj_Name__c,Status__c,Abstract__c
               FROM Project__c ];
    prj = new Project__c();

    catch(Exception ex)
        system.debug('Error message: '+ex.getMessage());

    return null;

public void initProjList(){
    lstproj = [SELECT Name,Proj_Name__c,Status__c,Abstract__c
               FROM Project__c ];

global static List<Project__c> DeleteProj(String projId) {

    Project__c[] proj;
    proj = [SELECT id,Name,Proj_Name__c,Status__c,Abstract__c
               FROM Project__c  WHERE Name = :projId];
    if(proj.size() > 0 || proj[0].Id != ''){
        delete proj;}
     List<Project__c> lstproj;
    lstproj = [SELECT Name,Proj_Name__c,Status__c,Abstract__c
               FROM Project__c ];

    return lstproj;      
  • Can you try immediate= true? – Shailesh Patil Mar 3 '17 at 7:25
  • I tried immediate = true. It did not help to fix the issue. – Saranya Mar 3 '17 at 7:37
  • Are you using docType as HTML 5? If yes, just use <apex:commandButton action="{!cancel}" value="Cancel" immediate="true" html-formnovalidate="formnovalidate" /> add html-formnovalidate. By the way, how are you making the field required? Client side or server side? – Shailesh Patil Mar 3 '17 at 7:46
  • I am not worried about the cancel button. If you check the left side of the image, you will see a delete button on every row. This button is not working as expected. It supposed to delete the record using remote function and rerender the leftside panel. It is not rerendering the panel as expected – Saranya Mar 3 '17 at 9:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.