+ Start a Discussion
Eric Blaxton 11Eric Blaxton 11 

Visual Force Page Save button does not work in Lightning

Hi and appreciate any insight on this.

My save button no longer works.  It was a VS button.  I made a new List View button calling VFP/ APEX  Not sure what went wrong here.  

Button
 
User-added image

VFP.
<apex:page standardController="Case" recordSetVar="cases" lightningStylesheets="true" extensions="setQuickCaseExtensionController"> 
    <apex:form >
        <apex:pageBlock title="Quick Case Entry" mode="edit">
            <apex:pageMessages id="showmsg"></apex:pageMessages>
            
            <apex:pageBlockSection title="Case Details" columns="1">                 
                                
              <apex:inputField label="Source Type" required="true" value="{!case.Source_Type__c}" /> 
              <apex:inputField label="Origin" required="true" value="{!case.Origin}"/>  
              <apex:inputField label="Contact" value="{!case.ContactId}"/> 
              <apex:inputField label="Subject" required="true" value="{!case.Subject}"/> 
              <apex:inputTextArea style="width:300px;height:100px" required="true" label="Description (Min 10 chars)"  value="{!case.Description}"/>
              <apex:inputField label="Category" required="true" value="{!case.Category__c}"/> 
              <apex:inputField label="Sub-Catagory 1" required="true" value="{!case.Sub_Catagory_1__c}"/>  
              <apex:inputField label="Sub-Catagory 2" required="true" value="{!case.Sub_Category_2__c}"/>  
              <apex:inputField label="Sub-Catagory 3" required="true" value="{!case.Sub_Category_3__c}"/>              
              <apex:inputField value="{!case.Related_Account__c}" label="Account"/>          
              <apex:inputField value="{!case.Incident_Occurence_Date__c}" label="Incident Occurrence Date"/>
              <apex:inputField value="{!case.Incident_Occurrence_Time__c}" label="Incident Occurrence Time"/>  
             </apex:pageBlockSection>   
            
            <apex:pageBlockButtons > 
                <apex:commandButton value="Save & Close Quick Case" action="{!save}"/> 
                <apex:commandButton value="Cancel" action="{!cancel}"/> 
            </apex:pageBlockButtons> 
                       
          
        </apex:pageBlock> 
    </apex:form>
</apex:page>

APEX Class

public class setQuickCaseExtensionController {
   private Case QC; 
   public ApexPages.StandardSetController stdController; 
   public setQuickCaseExtensionController(ApexPages.StandardSetController controller){
        controller.setPageSize(10);
        this.QC = (Case)controller.getRecord(); 
        RecordType RecId = new RecordType();
        RecId=[SELECT Id FROM RecordType where Name='Customer First' LIMIT 1];
        QC.RecordTypeId=RecId.Id;
        QC.Quick_Case__c = True;
        QC.Origin = 'Phone';
        QC.Source_Type__c = 'Consumer';
        QC.Description='Quick Case';
        QC.Quick_Case_Closed__c = True;
        QC.Subject='New Quick Case';
        stdcontroller=controller;        
    }

}
Best Answer chosen by Eric Blaxton 11
Dushyant SonwarDushyant Sonwar
Remove recordsetvar attribute
and use this below line and have a list button with content as URL

<apex:page standardController="Case" lightningStylesheets="true" extensions="setQuickCaseExtensionController">

Let us know if problem persists.

 

All Answers

Dushyant SonwarDushyant Sonwar
Create a List View Button and select content Source as URL not visualforce page.

User-added image

User-added image

Add /apex/CustFirstQuickCase this in the source
and do the below changes in your code.

Save button will work fine.
 
<apex:page standardController="Case" lightningStylesheets="true" > 
    <apex:form >
        <apex:pageBlock title="Quick Case Entry" mode="edit">
            <apex:pageMessages id="showmsg"></apex:pageMessages>
            
            <apex:pageBlockSection title="Case Details" columns="1">                 
                                
              <apex:inputField label="Source Type" required="true" value="{!case.Source_Type__c}" /> 
              <apex:inputField label="Origin" required="true" value="{!case.Origin}"/>  
              <apex:inputField label="Contact" value="{!case.ContactId}"/> 
              <apex:inputField label="Subject" required="true" value="{!case.Subject}"/> 
              <apex:inputTextArea style="width:300px;height:100px" required="true" label="Description (Min 10 chars)"  value="{!case.Description}"/>
              <apex:inputField label="Category" required="true" value="{!case.Category__c}"/> 
              <apex:inputField label="Sub-Catagory 1" required="true" value="{!case.Sub_Catagory_1__c}"/>  
              <apex:inputField label="Sub-Catagory 2" required="true" value="{!case.Sub_Category_2__c}"/>  
              <apex:inputField label="Sub-Catagory 3" required="true" value="{!case.Sub_Category_3__c}"/>              
              <apex:inputField value="{!case.Related_Account__c}" label="Account"/>          
              <apex:inputField value="{!case.Incident_Occurence_Date__c}" label="Incident Occurrence Date"/>
              <apex:inputField value="{!case.Incident_Occurrence_Time__c}" label="Incident Occurrence Time"/>  
             </apex:pageBlockSection>   
            
            <apex:pageBlockButtons > 
                <apex:commandButton value="Save & Close Quick Case" action="{!save}"/> 
                <apex:commandButton value="Cancel" action="{!cancel}"/> 
            </apex:pageBlockButtons> 
                       
          
        </apex:pageBlock> 
    </apex:form>
</apex:page>

Hope this helps!
Eric Blaxton 11Eric Blaxton 11
Hi Dushyant,

Thanks for your time on this.

Your suggestion works and the Save works as planned.  Focus is set on the case as planned.

The issue is I need the call to the Apex class to determine the Record Type etc.  When I add the call to the Apex class, the save does not work.

I am working on converting a VS button to a lightning button.  This code seems like it should work without issue.  

Regards,
Eric
Dushyant SonwarDushyant Sonwar
You need to do some  changes in the apex class.
 
public class setQuickCaseExtensionController {

 
   public setQuickCaseExtensionController(ApexPages.StandardController controller){

         
        RecordType RecId = new RecordType();
        RecId=[SELECT Id FROM RecordType where Name='Customer First' LIMIT 1];
        controller.getRecord().put('RecordTypeId' , RecId.Id);
        controller.getRecord().put('Subject' , 'New Quick Case');
        controller.getRecord().put('Quick_Case__c' , true);
        controller.getRecord().put('Origin' , 'Phone');
        controller.getRecord().put('Source_Type__c' , 'Consumer');
        controller.getRecord().put('Quick_Case_Closed__c' , 'Quick Case');
        controller.getRecord().put('Description' , true);
        
        
    }

}



<apex:page standardController="Case" lightningStylesheets="true" extensions="setQuickCaseExtensionController">


This should work fine. The save button will work as expected.

Hope this helps!
Eric Blaxton 11Eric Blaxton 11
Getting closer back to the original code, but now get a new error

User-added image

<apex:page standardController="Case" recordSetVar="cases" lightningStylesheets="true" extensions="setQuickCaseExtensionController" >
​​​​​​​
Dushyant SonwarDushyant Sonwar
Remove recordsetvar attribute
and use this below line and have a list button with content as URL

<apex:page standardController="Case" lightningStylesheets="true" extensions="setQuickCaseExtensionController">

Let us know if problem persists.

 
This was selected as the best answer
Dushyant SonwarDushyant Sonwar
Sorry ,

there is some typo error

Replace this line

controller.getRecord().put('Quick_Case_Closed__c' , 'Quick Case');

with 
controller.getRecord().put('Quick_Case_Closed__c' , true);

and

this
controller.getRecord().put('Description' , true);
with
controller.getRecord().put('Description' , 'Quick Case');

 
Eric Blaxton 11Eric Blaxton 11
Hi Dushyant,

I already fixed those typo's.  Thank you for following up.    

Those suggestions worked.  Very good and thanks for your help.

Eric
Eric Blaxton 11Eric Blaxton 11
I don't quite understand, but glad this worked.