You need to sign in to do that
Don't have an account?
sksfdc221
Error: Id not specified in the update call
Below is my apex method where I'm updating Account_Transfer__c Records
Can anyone please suggest if there is anything missing
private static void linkPoliciesAndHandleApprovalFlds( List<string> selectedPoliciesSet, Account_Transfer__c accTrans, Office__c toOffice, Office__c fromOffice ) { Map<Id, Account_Transfer__c> AcctransMap = new Map<Id, Account_Transfer__c>(); String districtAccountCode = ''; List<Policy__c> selectedPolicies = new List<Policy__c>( [ SELECT Id, District_Acct_code__c, Account_Transfer__c, Plan_Code__c FROM Policy__c WHERE ID IN :selectedPoliciesSet ] ); List<Account_Transfer_Policy__c> accTransferPolicy = new List<Account_Transfer_Policy__c>(); for (Policy__c pol : selectedPolicies) { Account_Transfer_Policy__c atp = new Account_Transfer_Policy__c(); atp.Account_Transfer__c = accTrans.Id; atp.Policy__c = pol.Id; accTransferPolicy.add(atp); } accTrans.District_To__c = districtAccountCode; AcctransMap.put(accTrans.id, accTrans); update AcctransMap.values(); insert accTransferPolicy; Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest(); req.setObjectId(accTrans.Id); req.setSubmitterId(UserInfo.getUserId()); Approval.process(req); }Now this code isn't throwing me any errors but in the record page, I'm getting the error as
System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []I am using Map here to get the ids of Account Transfer records and using them to update by calling map.values(). I'm wondering why it is mentioning that Ids are not specified in the update call.
Can anyone please suggest if there is anything missing
You are Updating AcctransMap.values(), which is basically referring accTrans variable and throwing DMLexception. Because, to update any record you have to mention that record Id in accTrans variable. like accTrans.id = SFDC id Account_Transfer__c rec.
Update your code with the above changes and let me know if it works for you.
Regards,
Surojit
@Surojit, below is my complete code.
I am inserting Account_Transfer__c records in my insertAccountTransfer method and later updating them in linkPoliciesAndHandleApprovalFlds.
The issue here is that, I could not able to update the records which are inserted in the first method.
Could you please help me with this.
Can you set a debug log to get the Account_Transfer__c Id after line: 67 It shuould be null and for the same you are receiving the error. Please check and let me know what you receive in the apexlog
Regards,
Surojit