Getting CrmSdk.Picklist in the Grid

May 31, 2010 at 11:14 PM

Rather than getting the values of picklist and datetime and I'm assuming any other crm datatype other than string, I get the object name.

Any solution?

 

Dec 1, 2010 at 3:03 PM

Wdwcrazy,

I don't know if this is still an open issue for you (I guess not), but I've resolved  the issue as following.  After you've talked with your "Webservice" you generate your own "DataTable".  Doing that you are able to fill in the cells as you wish :

.....
String[] result = new String[] { "{2D22C107-A1C1-DF11-A6F2-005056BF5B64}" }; //GUIDS NEEDED
String[] columns = new String[] { "name", "accountid", "ave_shortname", "customertypecode", "parentaccountid", "ave_primaryproductfamilyid", "ownerid", "telephone1", "address1_city", "primarycontactid" };
dataSource = myFunctions.convertBusnessEntityCollectionToDataTable(GetDataSourceList(args, result, columns, account", "accountid", "name"), columns);
....

The "GetDataSourceList" is the "Webservice"-call and returns a "List<Dynamicentity>()"!  The "ConvertBusinessEntityCollectionToDataTable"-function takes a "List<DynamicEntity>()" as Input and then converts the List to a DataTable!  You loop trough all the "Entities" and you fill in a datarow of the datatable according to the "DynamicEntity". While converting from "DynamicEntity" to "DataRow" you can customize your "Data" => For ex. for Customer :

if (propType.Name == "CustomerProperty")
{
 Customer myProp = ((CustomerProperty)inputProperty).Value;
 if (myProp.type == "account")
 {
  propValue = String.Format("<img src=\"Images/ico_16_4006.gif\" class=\"menuImage\"/><span title=\"{2}\" style=\"text-decoration:underline;\" onmouseover=\"this.style.cursor='hand';\" onmouseout=\"this.style.cursor='default';\" onclick=\"OpenWindowType('{0}', '{1}')\">{2}</span>", ((CustomerProperty)inputProperty).Value.Value.ToString(), myProp.type.ToString(), ((CustomerProperty)inputProperty).Value.name.ToString());
 }
 else if (myProp.type == "contact")
 {
  propValue = String.Format("<img src=\"Images/ico_16_2_d.gif\" class=\"menuImage\"/><span title=\"{2}\" style=\"text-decoration:underline;\" onmouseover=\"this.style.cursor='hand';\" onmouseout=\"this.style.cursor='default';\" onclick=\"OpenWindowType('{0}', '{1}')\">{2}</span>", ((CustomerProperty)inputProperty).Value.Value.ToString(), myProp.type.ToString(), ((CustomerProperty)inputProperty).Value.name.ToString());
 }
}

You can put whatever you want in the span, you'll only see the "Value" in the SPAN as result in the "DataGrid"! 

I hope you understand what I mean and I hope I can help other people like that!

Kind Regards,
Frederic