I am trying to perform the following procedure:
String tipoInt = 'Account';
List<SObject> sl = new List<SObject>();
Sobject so = Schema.getGlobalDescribe().get(tipoInt).newSObject();
so.put('name', 'Endrit');
so.put('Test_External_Id__c', '1');
sl.add(so);
Sobject so2 = Schema.getGlobalDescribe().get(tipoInt).newSObject();
so2.put('name', 'Dori');
so2.put('Test_External_Id__c', '2');
sl.add(so2);
upsert sl Account.Fields.Test_External_Id__c;
According to this reference: https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dml_section.htm#apex_dml_upsert
This code should work. Instead it returns the following error:
Upsert with a field specification requires a concrete SObject type
I am choosing a different path to avoid this obstacle, but if I could solve it through this approach, would save me a lot of work.
Account.Fields.Test_External_Id__c
in yourupsert
?