You need to sign in to do that
Don't have an account?
How can I find a value of a field in a field set?
I have code that returns a fieldset based on a field's value (e.g. if Field is X, returns fieldset X but if Field is Y, returns fieldset Y. It then cycles through and adds up the number of fields in the fieldset. Next, I'd like to be able to cycle through each field and if its value is "Yes", then add a count. Below is a code snippet. Obviously, the if(lead[f.getFieldPath()] == 'Yes') line does not work. How can I find the value of the fieldsetmember? I also tried constructing a database.query (string query = 'Select ' + f.getFieldPath() + ' from lead where id =: lead.id'), but then I can't figure out how to query the result just for the field value.
if (fsMap.get(strProgram) != null){
for(Schema.FieldSetMember f : fsMap.get(strProgram).getFields()) {
TotalPreReqs += 1;
if(lead[f.getFieldPath()]== 'Yes'){
PreReqCount += 1;
}
}//end cycle through fieldset
}
if (fsMap.get(strProgram) != null){
for(Schema.FieldSetMember f : fsMap.get(strProgram).getFields()) {
TotalPreReqs += 1;
if(lead[f.getFieldPath()]== 'Yes'){
PreReqCount += 1;
}
}//end cycle through fieldset
}
if((String)Lead.get(f.getFieldPath()) == 'Yes') ...
All Answers
if((String)Lead.get(f.getFieldPath()) == 'Yes') ...