1

I have below code to fetch field values from records of Database.Saveresult.

I am getting error as below. Error

Expression of type Database.SaveResult has no member named Territory_Name__c

Code

for (Database.SaveResult sr : srList) {
        if (sr.isSuccess()) {
             Business_Plan_Approval_Process_Data_abv__c bpdata = new   Business_Plan_Approval_Process_Data_abv__c();
             bpdata.Business_Plan_Approval_Process_abv__c= sr.getId();  
             bpdata.Territory_abv__c= sr.Territory_Name__c;
             //Alstitem.External_ID_vod__c = actID+'-'+key;
             insbpdata.add(bpdata);
        }
    }
| improve this question | | | | |
3

You need to rewrite your code like following

srList = Database.upsert( records, false );
for (Integer i = 0; i < srList.size(); i++ ) {
     Database.SaveResult sr = srList[i];
        if (sr.isSuccess()) {
             Business_Plan_Approval_Process_Data_abv__c bpdata = new   Business_Plan_Approval_Process_Data_abv__c();
             bpdata.Business_Plan_Approval_Process_abv__c= sr.getId();  
             bpdata.Territory_abv__c= records[i].Territory_Name__c;
             //Alstitem.External_ID_vod__c = actID+'-'+key;
             insbpdata.add(bpdata);
        }
    }
| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.