I got myself into the server and I have retrieved (hopefully) the correct set of data. Then, I tried to list all the companies by the following code.
EntityCollection result = proxy.RetrieveMultiple(expression);
foreach (var entity in result.Entities)
{
String output = String.Empty;
if (entity.Attributes.Contains("account"))
output = entity.Attributes["account"].ToString();
}
However, it'd be nice to run an inner loop that goes through all the available attributes in result.Entities
. Should I use entity.Attributes.Keys
or is there a better method?
With lookup fields, you can define views that display different sets of values from the associated entity. So the options a user sees on one form using the lookup could be different from the options a user sees for the same lookup on another form by using different filtered views.
There are four different types of entity ownership.
You can go into the default Lookup View for the table and do a "Save As" to create a custom Lookup view and then utilize this one instead of the default with the columns you would like (the first two in the view will show in that lookup field). You can set this as the default view for that lookup field on the form.
I think this should do the trick.
foreach (Entity entity in result.Entities)
{
foreach (KeyValuePair<String, Object> attribute in entity.Attributes)
{
Console.WriteLine(attribute.Key + ": " + attribute.Value);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With