You need to sign in to do that
Don't have an account?
C# - Finding if object.FieldArray contains a Field.Name = "OwnerId"
Hey folks, I'm looping through a field array, checking to see if each and every field has a name property equal to "OwnerId" in order to answer the question "Does the object have an OwnerID"?
I want to optimize (less code, more efficient) this code a little bit. Do you have any suggestions?
the object "describeobject" in the first line is a DescribeSObjectResult.
sf.Field[] objectfields = describeobject.fields;
bool hasownerfield = false;
foreach (sf.Field objectfield in objectfields)
{
if (objectfield.name == "OwnerId")
{
hasownerfield = true;
}
}
Many thanks,
Isaac