List<Database.UpsertResult> productUpsertList = Database.upsert(productList,false);
Id productId; for (Database.UpsertResult ProdUpsert : productUpsertList ){ if (ProdUpsert .isSuccess()) { productId = ProdUpsert .getId();
But for the failed records I want to get the product description, And product Name both.
Is there a way I can do that ?Hi Levy,Please follow below code:-
if you need any assistanse, Please let me know!!List<Database.UpsertResult> productUpsertList = Database.upsert(productList,false);
Map<Id, Product> productMap = new Map<Id, Product>(productList);
Id productId;
for (Database.UpsertResult ProdUpsert : productUpsertList ){
if (ProdUpsert .isSuccess()) {
System.debug(productMap.get(ProdUpsert.getId()).Name);
System.debug(productMap.get(ProdUpsert.getId()).Description);
//productId = ProdUpsert .getId();
}
}
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh