You need to sign in to do that
Don't have an account?
TUSHAR KHORGADE
getting error in update field
System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []
public with sharing class InvestmentController {
@AuraEnabled(cacheable=true)
public static List<HSA_Investment__c> fetchInvestment() {
List<HSA_Investment__c> invest = [SELECT Id,Name,Company_Sector__r.Name,Fund_Released_Date__c
FROM HSA_Investment__c];
System.debug('In the fetch ' +invest );
return invest;
}
@auraEnabled
public static void savePriceValue(List<Integer> InvestmentPrice){
System.debug('check me ' + InvestmentPrice);
List<HSA_Investment__c> priceUpdate = new List<HSA_Investment__c>();
for(Integer i=0; i<InvestmentPrice.size(); i++){
HSA_Investment__c empCardObj = new HSA_Investment__c();
empCardObj.NAV__c= InvestmentPrice[i];
priceUpdate.add(empCardObj);
}
system.debug('price updateddd'+ priceUpdate);
update priceUpdate;
//return priceUpdate;
}
}
public with sharing class InvestmentController {
@AuraEnabled(cacheable=true)
public static List<HSA_Investment__c> fetchInvestment() {
List<HSA_Investment__c> invest = [SELECT Id,Name,Company_Sector__r.Name,Fund_Released_Date__c
FROM HSA_Investment__c];
System.debug('In the fetch ' +invest );
return invest;
}
@auraEnabled
public static void savePriceValue(List<Integer> InvestmentPrice){
System.debug('check me ' + InvestmentPrice);
List<HSA_Investment__c> priceUpdate = new List<HSA_Investment__c>();
for(Integer i=0; i<InvestmentPrice.size(); i++){
HSA_Investment__c empCardObj = new HSA_Investment__c();
empCardObj.NAV__c= InvestmentPrice[i];
priceUpdate.add(empCardObj);
}
system.debug('price updateddd'+ priceUpdate);
update priceUpdate;
//return priceUpdate;
}
}
For any update you perform you need to mention the Id of the record. Or else system will not understand which record it should update.
In the below line of code you are not adding the id of the record.
Please mention the id of the record and perform the operation.
If this solution helps, Please mark it as best answer.
Thanks,