
Upsert failed. First exception on row 0; first error: DUPLICATE_EXTERNAL_ID, System Month: more than one record found for external id field: [a19e0000000XQCIAA4, a19e0000000XQO4AAO, a19e0000000XQHIAA4]: [SystemMonth__c]
Country__c period = [select Id,CurrentSystemMonth__c,CurrentSystemYear__c from Country__c where CountryCode__c='UK'];
List<Adjustment__c> adjustment = new List<Adjustment__c>();
adjustment=[select Amount__c,VAT__c,Customer__c,DealID__c,Syetem_Month__c,System_Year__c from Adjustment__c where Status_code__c = 'APR' and Syetem_Month__c =: period.CurrentSystemMonth__c and System_Year__c =: period.CurrentSystemYear__c];
List<Payments__c> payment = new List<Payments__c>();
Payments__c erspay=new Payments__c();
for(ERS_Adjustment__c adjlist : adjustment)
{
erspay.Adjustment_value__c=adjlist.Amount__c;
erspay.Adjustment_VAT__c=adjlist.VAT__c;
erspay.CustomerNo__c=adjlist.ERS_Customer__c;
erspay.SystemMonth__c=adjlist.Syetem_Month__c;
erspay.SystemYear__c=adjlist.System_Year__c;
erspay.DealID__c=adjlist.DealID__c;
payment.add(erspay);
}
if(payment.size()>0)
{
upsert payment SystemMonth__c;
}
답변 7개
External IDs always have to be unique regardless of how they are populated.