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
D0TD0T 

MISSING_ARGUMENT, Id not specified in an update call??

Hi, 

 

Getting " Update failed. First exception on row 1; first error: MISSING_ARGUMENT, Id not specified in an update call: []" error when trying to do a bulk update on the Team Member Role . from "Technical Analyst" to "Benefit Analyst" to ensure the code below is activated.

 

Please help.

 

-------------------

 

trigger trgAfterTeamMember on Company_Team__c (after insert, after update) {
    
    Set<Id> accountIds = new Set<Id>();
    List<Account> accountsToUpdate = new List<Account>();
    
    for(Company_Team__c tm : trigger.new) {
        //if(tm.Team_Member_Role__c == 'Analyst' || tm.Team_Member_Role__c == 'Benefit Analyst') {
            //accountsToUpdate.add(new Account(Id = tm.Company__c, Analyst__c = tm.Team_Member__c));
        //}
        accountIds.add(tm.Company__c);
    }
    
    if(!accountIds.isEmpty()) {
        for(id i : accountIds) {
            accountsToUpdate.add(new Account(Id = i));
        }
        database.update(accountsToUpdate);
    }
    //if(!accountsToUpdate.isEmpty()) {
    
        //try {
        //    database.update(accountsToUpdate);
        //}
        //catch(Exception e) { System.debug(' Error: ' + e ); }
    //}
}

SScholtzSScholtz

Can you provide more information?  Are you using the Apex Data Loader to do your update?  Did you map your Id fields to each other?

D0TD0T

Yes using Data Uploader I tried the "update" and "upsert" calls. 

 

I exported the DATA using APEX Dataloader, changed the Team Role Name from Technical to Benefit. Then saved it > When I tried to update I got the error message above.

 

 

SScholtzSScholtz

When you're doing your import, on Step 3, make sure you're hitting the "Create or Edit Map" button and matching the fields up right.  Match Team_Member_Role__c  to Team_Member_Role__c, and Id to Id.

 

You need to have an Id in order to make an update or upsert, something for the Apex Data Loader to make matches on to find the records you want to update. (upserts can be a little different thanks to External IDs, but that's something else)

D0TD0T

I did, see screenshot. 

Uploaded with ImageShack.us
SScholtzSScholtz

Hmmmm...stupid question on my part, but check your CSV, the ID column has values?  And look at the error CSV file, it spits back everything you tried to import, plus the error message.  Does the ID column have a value?

 

Also look at the error message, does it say anything more beyond what you quoted?  I'm wondering if the error message has less to do with the bulk update and more to do with a trigger attached to the object you're trying to update.

 

Your trigger, as written, just adds tm.Company__c to your Set without checking its value.  Is it possible that some of your Company_Team__c.Company__c values are null?

 

And when you made your edit, did you do it in Excel or a text editor?  If Excel, pop your saved CSV file open in a text editor and make sure Excel didn't replace all the commas with tabs instead. (This probably isn't the issue, as you'd be getting errors earlier in your process)

 

 

D0TD0T

Here is the full error.

 

trgAfterTeamMember: execution of AfterUpdate

caused by: System.DmlException: Update failed. First exception on row 1; first error: MISSING_ARGUMENT, Id not specified in an update call: []

Trigger.trgAfterTeamMember: line 17, column 9

SScholtzSScholtz

Yea bingo, it doesn't have anything do with bulk update, it has to do with your trigger failing.

 

Change this....

    for(Company_Team__c tm : trigger.new) {
        //if(tm.Team_Member_Role__c == 'Analyst' || tm.Team_Member_Role__c == 'Benefit Analyst') {
            //accountsToUpdate.add(new Account(Id = tm.Company__c, Analyst__c = tm.Team_Member__c));
        //}
        accountIds.add(tm.Company__c);
    }

 

...to this...

 

    for(Company_Team__c tm : trigger.new) {
        //if(tm.Team_Member_Role__c == 'Analyst' || tm.Team_Member_Role__c == 'Benefit Analyst') {
            //accountsToUpdate.add(new Account(Id = tm.Company__c, Analyst__c = tm.Team_Member__c));
        //}
        if (tm.Company__c != null) {
          accountIds.add(tm.Company__c);
        }
    }

 

That will make sure accountIds actually has Ids in it.  Give that a shot...

D0TD0T

I got this error when I added your code and tried to promote it. " Average test coverage across all Apex Classes and Triggers is 0%, at least 75% test coverage is required "

 

So I reverted back to the old settings and changed the value in code from Benefit Analyst to Technical Analyst. 

 

Is there a way to reintiate the code so that My salesforce sees the changes in the code?

D0TD0T

Reason to why I'm asking is because when I add a new team member with the ROLE : Technical Analyst the name of the team member should be prepopulated in the Reminders Sent to field on the Account object..and it isnt. But If I change it to Benefit Analyst in the code the name of the Analyst is updated. So I'm wondering if I can force the code to be executed to force the new changes.

 

 

By the way everything was working fine, until I changed the picklist value in the team role name from Beenfit Analyst to Technical Analyst.

 

Thanks.

SScholtzSScholtz

The code coverage error is because you need to write Test Classes for your code.  SF won't let you promote code to a production environment unless your code has been covered with tests.  You can read more here: http://wiki.developerforce.com/page/An_Introduction_to_Apex_Code_Test_Methods

 

Are you working on a production environment or a development sandbox?  Or do you only have a production environment?

 

re: reinitiate...not sure I follow?

D0TD0T

I have a Sandbox. Incase you didnt read my last response. 

 

Reason to why I'm asking is because when I add a new team member with the ROLE : Technical Analyst the name of the team member should be prepopulated in the Reminders Sent to field on the Account object..and it isnt. But If I change it to Benefit Analyst in the code the name of the Analyst is updated. So I'm wondering if I can force the code to be executed to force the new changes.

 

 

By the way everything was working fine, until I changed the picklist value in the team role name from Benefit Analyst to Technical Analyst.

 

Thanks.

steve456steve456

This error comes when u try update the record without inserting........first insert thn update  ....it should work

D0TD0T

I think I may have found the solution to this. Will report back tomorrow.

 

Thanks for your help.