Answered by:
How to get the values of the all the option set type in the contact entity?

Question
-
Dear all,
How to get the values of the all the option set type in the contact entity? using custom c# coding
Thanks in advance..
Thursday, June 21, 2012 11:38 AM
Answers
-
Hi Deep,
You can get the attribute type by checking
if (Attr.Value is OptionSetValue) { }
- Proposed as answer by Suresh Kumar Patra Thursday, June 21, 2012 12:01 PM
- Marked as answer by Deepthi_1988 Friday, June 22, 2012 5:06 PM
Thursday, June 21, 2012 12:01 PM -
You need to use the metadata services
RetrieveAttributeRequest retrieveAttributeRequest =
new RetrieveAttributeRequest
{
EntityLogicalName = Contact.EntityLogicalName,
LogicalName = "new_picklist",
RetrieveAsIfPublished = true
};
// Execute the request.
RetrieveAttributeResponse retrieveAttributeResponse =
(RetrieveAttributeResponse)_serviceProxy.Execute(
retrieveAttributeRequest);
// Access the retrieved attribute.
PicklistAttributeMetadata retrievedPicklistAttributeMetadata =
(PicklistAttributeMetadata)
retrieveAttributeResponse.AttributeMetadata;
// Get the current options list for the retrieved attribute.
OptionMetadata[] optionList =
retrievedPicklistAttributeMetadata.OptionSet.Options.ToArray();check the whole sample here http://www.resultondemand.nl/support/sdk/377198f5-ac08-40e1-a727-f3ac51e7a01e.htm
I hope this helps.
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Amreek Singh Senior CRM Consultant CDC Praxa Sydney, Australia http://mscrmshop.blogspot.com http://crm2011usersettings.codeplex.com
- Proposed as answer by Amreek Singh Thursday, June 21, 2012 12:05 PM
- Marked as answer by Deepthi_1988 Friday, June 22, 2012 5:07 PM
Thursday, June 21, 2012 12:05 PM
All replies
-
Hi Deep,
You can get the attribute type by checking
if (Attr.Value is OptionSetValue) { }
- Proposed as answer by Suresh Kumar Patra Thursday, June 21, 2012 12:01 PM
- Marked as answer by Deepthi_1988 Friday, June 22, 2012 5:06 PM
Thursday, June 21, 2012 12:01 PM -
You need to use the metadata services
RetrieveAttributeRequest retrieveAttributeRequest =
new RetrieveAttributeRequest
{
EntityLogicalName = Contact.EntityLogicalName,
LogicalName = "new_picklist",
RetrieveAsIfPublished = true
};
// Execute the request.
RetrieveAttributeResponse retrieveAttributeResponse =
(RetrieveAttributeResponse)_serviceProxy.Execute(
retrieveAttributeRequest);
// Access the retrieved attribute.
PicklistAttributeMetadata retrievedPicklistAttributeMetadata =
(PicklistAttributeMetadata)
retrieveAttributeResponse.AttributeMetadata;
// Get the current options list for the retrieved attribute.
OptionMetadata[] optionList =
retrievedPicklistAttributeMetadata.OptionSet.Options.ToArray();check the whole sample here http://www.resultondemand.nl/support/sdk/377198f5-ac08-40e1-a727-f3ac51e7a01e.htm
I hope this helps.
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Amreek Singh Senior CRM Consultant CDC Praxa Sydney, Australia http://mscrmshop.blogspot.com http://crm2011usersettings.codeplex.com
- Proposed as answer by Amreek Singh Thursday, June 21, 2012 12:05 PM
- Marked as answer by Deepthi_1988 Friday, June 22, 2012 5:07 PM
Thursday, June 21, 2012 12:05 PM