You need to sign in to do that
Don't have an account?
swain 10
how to put list<sobject> collection field in map key value pair .........Showing Error
List<sObject> allResult= OV_Searchcc360.isDuplicate(objectType, fields, sources, null);
So allResult is a List of array having multiple records of one object , each record having several fields. I need to use 2 fields from this collection in a key value pair ie:- Id and Score field present inside the array. so i written this below code to iterate.
List<Map<String,String>> allResultMap = new List<Map<String,String>>();
for(sObject objSObject : allResult)
Map<String,String> finalResultMap = new Map<String,String>();
{
allResultMap.put(objSObject.DSE__DS_Account__c, objSObject.DSE__DS_Score__c);
system.debug('-------allResultMap-----'+allResultMap);
}
But it is showing that value doesnt exist :DSE__DS_Account__c and DSE__DS_Score__c. But both fields present in the array. Please help.
And after this I need to sort according to score points.
So allResult is a List of array having multiple records of one object , each record having several fields. I need to use 2 fields from this collection in a key value pair ie:- Id and Score field present inside the array. so i written this below code to iterate.
List<Map<String,String>> allResultMap = new List<Map<String,String>>();
for(sObject objSObject : allResult)
Map<String,String> finalResultMap = new Map<String,String>();
{
allResultMap.put(objSObject.DSE__DS_Account__c, objSObject.DSE__DS_Score__c);
system.debug('-------allResultMap-----'+allResultMap);
}
But it is showing that value doesnt exist :DSE__DS_Account__c and DSE__DS_Score__c. But both fields present in the array. Please help.
And after this I need to sort according to score points.
Map<ID, String> newMap = new Map<ID, String>(); //created a new map
for(sObject s : allResult)
{
newMap.put(s.id, s.score__c);
}