You need to sign in to do that
Don't have an account?
ShadowlessKick
Capture SObject Set <String> Element
Am getting this error:
Initial term of field expression must be a concrete SObject: SET<String>
Any ideas?
global Set<String> TheCoorNames = new Set<String>();
TheCoorNames.add("James Jones");
TheCoorNames.add("Sue Smith");
for (Integer TheIndex = 0; TheIndex < TheCoorNames.size(); TheIndex++){
String TheName;
TheName = TheCoorNames.get[TheIndex].tostring;
}
Initial term of field expression must be a concrete SObject: SET<String>
Any ideas?
global Set<String> TheCoorNames = new Set<String>();
TheCoorNames.add("James Jones");
TheCoorNames.add("Sue Smith");
for (Integer TheIndex = 0; TheIndex < TheCoorNames.size(); TheIndex++){
String TheName;
TheName = TheCoorNames.get[TheIndex].tostring;
}
Raveen Murugesan...noted there is not a get method in the Set<String> class.
The reason that a Set<String> was being utilized was that a Set<String> only allows unique values. Since that is what the process required, it seemed like the most logical path to take. Unfortunatly, it appears that there is no way to retrieve element values from a Set<String>.
Based on the suggestion from Raveen Murugesan the following was done. The unique values needed were collected in a Set<String>. (This guaranteed uniqueness.) The Set<String> was then loaded into a List<String>. The List<String> does provide a get method but does not guarantee uniqueness. Hokey, but I is what it is.
This is an example of what the code looked like:
All Answers
TheName = string.valueof(TheCoorNames.get[TheIndex]);
You need to change the code like this,
1. TheName = TheCoorNames.get[TheIndex].tostring; // bracket is wrong
it should be TheCoorNames.get(TheIndex)
2. Already the value is string no need to covert that again to string. Anyway to covert to string you should use like this
TheName = string.valueof(TheCoorNames.get(TheIndex));
3. There is no get method in set pls refer the following link you should you use list.
http://www.salesforce.com/us/developer/docs/dbcom_apex230/Content/apex_methods_system_set.htm
So your code should be like this
public list<String> TheCoorNames = new list<String>();
TheCoorNames.add('James Jones');
TheCoorNames.add('Sue Smith');
String TheName;
for (Integer TheIndex = 0; TheIndex < TheCoorNames.size(); TheIndex++){
TheName = String.valueOf(TheCoorNames.get(TheIndex));
}
system.debug('~~~~~~~~'+TheName);
Mark this as solution if you got an answer.
Thanks,
Praveen Murugesan.
Raveen Murugesan...noted there is not a get method in the Set<String> class.
The reason that a Set<String> was being utilized was that a Set<String> only allows unique values. Since that is what the process required, it seemed like the most logical path to take. Unfortunatly, it appears that there is no way to retrieve element values from a Set<String>.
Based on the suggestion from Raveen Murugesan the following was done. The unique values needed were collected in a Set<String>. (This guaranteed uniqueness.) The Set<String> was then loaded into a List<String>. The List<String> does provide a get method but does not guarantee uniqueness. Hokey, but I is what it is.
This is an example of what the code looked like: