You need to sign in to do that
Don't have an account?
Denis O'Leary
Map is losing it's value pair after upsert
Hi,
I have a map which consists of an sObject and a custom class, i'm mapping objects that i need to process to a class.
map<service_call__c, JobResponse> scTaskList = new map<service_call__c, JobResponse>();
My issue is I perform an upsert on the Service call object before I send this scTaskList map into another method for some further processing. After I perform that upsert the Service_call__c object that is in the map will get an ID assigned to it (if it wasn't an exisiting record) but it then looses it's mapped Job response.
Is there anything I can do to prevent this?
I have a map which consists of an sObject and a custom class, i'm mapping objects that i need to process to a class.
map<service_call__c, JobResponse> scTaskList = new map<service_call__c, JobResponse>();
My issue is I perform an upsert on the Service call object before I send this scTaskList map into another method for some further processing. After I perform that upsert the Service_call__c object that is in the map will get an ID assigned to it (if it wasn't an exisiting record) but it then looses it's mapped Job response.
Is there anything I can do to prevent this?
I reveresed the order in the Map from map<service_call__c, JobResponse> to map<JobResponse, service_call__c>. The issue it seems was to do with service_call__c changing after the Upsert (by it getting assigned an ID) that it now was a different Key in the map and therefore loosing it's value.
All Answers
Can you share the code around the upsert you are doing, would be helpful.
RD
I reveresed the order in the Map from map<service_call__c, JobResponse> to map<JobResponse, service_call__c>. The issue it seems was to do with service_call__c changing after the Upsert (by it getting assigned an ID) that it now was a different Key in the map and therefore loosing it's value.