You need to sign in to do that
Don't have an account?
swain 10
Set to store string of Ids from List<sobject> array
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 id from this collection in a Set. so i written this below code to iterate.
Set<String> resultIds = new Set<String>();
for (String sourceId : allResult.keySet())
{
resultIds.add(sourceId .DSE__DS_Account__c);
system.debug('-------resultIds-----'+resultIds);
}
I need help getting error
So allResult is a List of array having multiple records of one object , each record having several fields. I need to use id from this collection in a Set. so i written this below code to iterate.
Set<String> resultIds = new Set<String>();
for (String sourceId : allResult.keySet())
{
resultIds.add(sourceId .DSE__DS_Account__c);
system.debug('-------resultIds-----'+resultIds);
}
I need help getting error
You will have to first cast the sobject to your object.
You code should look like this:
Please note that this code will still give error because in 'DSE__DS_Account__c' you have double underscore and apex doesn't support that. So you will have to work your way around it.
Let me know if it helps
All Answers
You will have to first cast the sobject to your object.
You code should look like this:
Please note that this code will still give error because in 'DSE__DS_Account__c' you have double underscore and apex doesn't support that. So you will have to work your way around it.
Let me know if it helps
First there is no method in the List Class as Keyset() it will comes under map class only.
List<sObject> allResult= OV_Searchcc360.isDuplicate(objectType, fields, sources, null);
System.debug('@@@ allresult ' + allresult.size()); /// Check the debug did you have the values for Allresult List from above methosd call then only you will have the values in resultIds.
If(allResult.size() > 0)
{
System.debug('@@@ Inside loop');
Set<String> resultIds = new Set<String>();
for (String sourceId : allResult)
{
if(sourceId.DSE__DS_Account__c != null )
{
resultIds.add(sourceId.DSE__DS_Account__c);
system.debug('-------resultIds-----'+resultIds);
}
}
}
Can you please Let me know if it helps or not!!!
If it helps don't forget to mark this as a best answer!!!
Thanks,
Raj