Below is my apex method where I'm updating Account_Transfer__c Records
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 = new Account_Transfer__c();
}
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