06-21-2012 09:30 AM
Hello everyone,
I found my way to get selected opportunities and some of its fields but now I'm trying to access all the fields by mean rows on this selected opportunity I'm trying to do it from fields property but gives me "Parameter Name:realName" error. Any ideas about this.
Thanks.
06-22-2012 04:05 AM
yeh, my bad. For the values I think you want the mutableentityfielddescriptors
something alogn the lines of
MutableEntityFieldDescriptor[] oppfielddecriptors = framew.Opportunities.GetMutableEntityFieldDescriptors();
would do the trick.
so the below would, I think get the values for all fields for the current opportunity. Obviously, you'd use it differently, it's just an example. Also, you can set the opportunity object by getting the needed opportunity in another way, etc.
Opportunity o = application.ApplicationState.CurrentOpportunity;
foreach (MutableEntityFieldDescriptor field in oppfielddecriptors)
{
string value = Convert.ToString(field.GetValue(o));
}
06-21-2012 10:11 AM
Is there a particular field that you're trying to get? Have you verified that you're using the correct real name for the field?
This worked for me:
Opportunity myOpp = _ActApp.ApplicationState.CurrentOpportunity;
DBFieldDescriptor dbf = _ActApp.ActFramework.Opportunities.GetFieldDescriptor("TBL_OPPORTUNITY.USER1");
06-22-2012 01:27 AM - edited 06-22-2012 01:42 AM
Hello Matthew thank you for your reply I'm trying to get all the fields so I need their real names I think, where can I find them ? Find them Matthem thank you very much for your help..
06-22-2012 03:32 AM
if you have the opportunity object you can get all the fields for it into a fieldcollection. Here's some code from something i'm working on
Opportunity o = application.ApplicationState.CurrentOpportunity;
MutableEntity.FieldCollection oppfields = o.OpportunityFields;
you could potentially loop through these, etc.
06-22-2012 03:46 AM
Also, I'm not sure why but i found that
MutableEntityFieldDescriptor (and GetMutableEntityFieldDescriptor) worked better with opportunities in particular.
Also, you don't necessarily need real names - you can use the GetMutableEntityFieldDescriptor(name, fieldNameType) overload and pass the display name with fieldnametype.alias or fieldnametype.display
06-22-2012 03:56 AM
Hello Anton,
Thanks for the reply I'm trying your code as well but now my problem is I can get to the column names but I can't find the values inside the rows such as I found column name Company Name but I can't find the companies name in row like Microsoft. Could you post your complete code here?
Thanks
06-22-2012 04:05 AM
yeh, my bad. For the values I think you want the mutableentityfielddescriptors
something alogn the lines of
MutableEntityFieldDescriptor[] oppfielddecriptors = framew.Opportunities.GetMutableEntityFieldDescriptors();
would do the trick.
so the below would, I think get the values for all fields for the current opportunity. Obviously, you'd use it differently, it's just an example. Also, you can set the opportunity object by getting the needed opportunity in another way, etc.
Opportunity o = application.ApplicationState.CurrentOpportunity;
foreach (MutableEntityFieldDescriptor field in oppfielddecriptors)
{
string value = Convert.ToString(field.GetValue(o));
}
06-22-2012 04:15 AM
Thank you very much Anton that really do the trick, much appriciated.