You need to sign in to do that
Don't have an account?
Loop through fields?
I want to loop through all the fields on an opportunity and if they are a multi select pick list, add their name to a list. here is my non-working code:
Schema.DescribeSObjectResult dsr = Opportunity.sObjectType.getDescribe();
List<String> MPL= new List<String>();
for (Integer i=0; i < dsr.fields.Length; i++) {
if( dsr.fields[i].getType == 'MultiPicklist' )
{
MPL.Items.Add( dsr.fields[i].getLabel );
}
}
On the MPL.Items.Add( dsr.fields[i].getLabel ) line I get the following error:
Error: Compile Error: Expression must be a list type: Schema.SObjectTypeFields at line 13 column 36 |
From the documentation "getLabel" should return a string. I don't know why it's asking for a list type.