function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sreekanth NaraboinaSreekanth Naraboina 

Updating Existing case Records from Visual Force Page

Update Existing Record from Visual Force Page
Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []
Error is in expression '{!Save}' in component <apex:commandButton> in page massclosecasescontroller: Class.MassCloseCasesController.save: line 17, column 1
An unexpected error has occurred. Your development organization has been notified.
Apex class:
public with sharing class MassCloseCasesController {
   public string CaseId{get;set;}
    public List<Case> Caselist{get;set;}
    public Case Caserecord{get;set;}
    public MassCloseCasesController(ApexPages.StandardController controller) 
    {
    
    Caserecord =(Case)Controller.getRecord();
    Caseid = ApexPages.CurrentPage().getparameters().get('CaseId');
    
    System.debug('Case id='+Caseid);
        Caselist = [select id,Status,Notes__c from Case where id=:CaseId];
    
    }  
    
    public PageReference save(){ 
        update Caserecord;
        return null;
    }
      
     
  }
    
    Visualforce page:
<apex:page standardController="Case" extensions="MassCloseCasesController">

 <apex:form >
 <apex:sectionHeader title="Change Case Status"/>
 <apex:pageBlock title="Select New Status">
 <apex:pageBlockButtons >
 <apex:commandButton value="Save" action="{!Save}"/>
 
 </apex:pageBlockButtons>
 <apex:pageBlockSection columns="1">
 
 <apex:inputField value="{!Caserecord.Status}" style="width:15%"/>
 <apex:inputField value="{!Caserecord.Notes__c}" style="width:30%"/>
 
 
 </apex:pageBlockSection>
 </apex:pageBlock>
 </apex:form>
 </apex:page>

Please anyone help me asap.

Thanks,
Sreekanth
Madhukar_HeptarcMadhukar_Heptarc
Dear Sreekanth,
I understand your requirement
VF Page:
=======
<apex:page standardController="Case" extensions="MassCloseCasesController1">

 <apex:form >
 <apex:sectionHeader title="Change Case Status"/>
 <apex:pageBlock title="Select New Status">
 <apex:pageBlockButtons >
 <apex:commandButton value="Save" action="{!Save}"/>
 
 </apex:pageBlockButtons>
 <apex:pageBlockSection columns="1">
 
 <apex:inputField value="{!Caserecord.Status}" style="width:15%"/>
 <apex:inputField value="{!Caserecord.Notes__c}" style="width:30%"/> 
 
 
 </apex:pageBlockSection>
 </apex:pageBlock>
 </apex:form>
 </apex:page>

Apex Class :
=========

public class MassCloseCasesController1 {
 public string CaseId{get;set;}
    public List<Case> Caselist{get;set;}
    public Case Caserecord{get;set;}
    public MassCloseCasesController1(ApexPages.StandardController controller) 
    {
    
    Caserecord =(Case)Controller.getRecord();
    Caseid = ApexPages.CurrentPage().getparameters().get('CaseId');
    
    System.debug('Case id='+Caseid);
        Caselist = [select id,Status,Notes__c from Case where id=:CaseId];
    
    }  
    public PageReference save(){ 
        upsert Caserecord;
        return null;
    }
  }
Try the Above code to fix that error.
You Just need to change the DML Operation (Update to Upsert)
I verified in my Org. it working fine.

https://c.ap5.visual.force.com/apex/VF_Case?core.apexpages.request.devconsole=1?Id=5007F000002dEr8

When you run visualforce page try to pass Case Record ID in the URL You can refer above reference URL link.
Please let us know if it helps you. and please mark it as solved.

Regrads,
Madhukar.
 
Sreekanth NaraboinaSreekanth Naraboina
it is not working please let me know any hep?

 
Madhukar_HeptarcMadhukar_Heptarc
Dear Sreekanth,

Did you changed the DML operation Update call to Upsert Call.
If your done those changes, can please send me the screen shot of that, Where your are exactly facing the issue.
(or)
can please exaplin the indetail where your exactly getting the issue.


Regards,
Madhukar.