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
StaciStaci 

MISSING_ARGUMENT, Id not specified in an update call

I have a button on Cases called Create Alert.  It creates a record in our custom object Alerts.  I'm trying to get it to update a lookup to itself upon creation but can't seem to get it to update.  I want the Alert Id to be copied into the Master_Alert_Lookup__c field but i'm getting this error when I click save.  If I comment out the update line and look in debug logs, its pulling the correct ID, just not updating the current Alert record.  Can anyone help me with this please?

Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []

public class CW_casetoAlert{
public Alerts__c a{get; set;}


    public CW_casetoAlert(ApexPages.StandardController controller) {
        this.a=(Alerts__c)Controller.getrecord();
    }
   
     public pageReference autorun(){
          ID alertID = ApexPages.CurrentPage().getParameters().get('newid');
          ID caseID =  ApexPages.CurrentPage().getParameters().get('caseID');
        
        
         a.Master_Alert_Lookup__c = alertID;
         //Update the new Alert record
         update a;
         system.debug(a);
              
        //create a new Case Change Association
        Case_Alert_Association__c newCAA = new Case_Alert_Association__c();
         // Fill in the values for the new record
         newCAA.Case__c = caseID;
         newCAA.Alerts__c = alertID;
               
         //Insert the new Case Change Association record
          Database.insert (newCAA);  
       
        PageReference retPage = new PageReference('/' + alertID);
        return retPage;
       }


    }
JonathanBaltzJonathanBaltz
Hello,
Where are you setting the two page parameters (newId and caseId) and where is the autoRun() method being called?  From the button?
If this is the controller for the Alert__c record, and the current record is to be updated, have you tried getting the Id within the constructor through a getId() method? 
StaciStaci
newID and caseID I honestly copied from previous code, not really sure what it does(thought it was looking at the current alertID it was creating and the caseID the button was pushed on.
Button:
/a0H/e?retUrl={!Case.Id}&00Ne0000000jigT={!Case.Created_Date_For_IA__c}&00Ne0000000jigO={!Case.Incident_Start__c}&00Ne0000000jifu={!Case.Product__c}&CF00Ne0000000jigE={!Case.CaseNumber}&CF00Ne0000000jigE_lkid={!Case.Id}&CF00Ne0000000jigs={!Case.Account}&CF00Ne0000000jigs_lkid={!Case.AccountId}&saveURL=/apex/CW_CasetoAlert?caseID={!Case.Id}

My autoRun is being called from VF Page
<apex:page standardController="Alerts__c" extensions="CW_casetoAlert" action="{!autorun}">


   </apex:page>
JonathanBaltzJonathanBaltz
Hi Staci,
The problem is that there's no Id for the Alerts__c record being created until the record is saved. And do you see the last line in the button URL "caseID={!Case.Id}"?  That small part is assigning the Case Id to caseID, but I don't see any mention of newId. 

You might want to create a workflow that updates the Master_Alert_Lookup__c field when the Account record is created.