Retrieve OptionSet Lables using MsCrm 2011 SOAP Service in SilverLight

Retrieve OptionSet Lables using MsCrm 2011 SOAP Service in SilverLight

Follow the Below link to Add Class files to your Project “SilverlightExtensionMethods.cs ” and “SilverlightUtility.cs”

using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Animation;

using System.Windows.Shapes;

using MsCrmSoapService.CrmSdk;

using System.Text;

namespace MsCrmSoapService


public partial class MainPage : UserControl


public MainPage()




string lblStageValues;

private void OptionSetLabels(string entityName, string attributeName)


OrganizationRequest request = new OrganizationRequest();

request.RequestName = “RetrieveAttribute”;

request[“EntityLogicalName”] = “account”;

request[“LogicalName”] = “new_stage”;

request[“MetadataId”] = Guid.Empty;

request[“RetrieveAsIfPublished”] = true;

IOrganizationService service = SilverlightUtility.GetSoapService();

service.BeginExecute(request, new AsyncCallback(Callback), service);


private void Callback(IAsyncResult result)






StringBuilder sb = new StringBuilder();

OrganizationResponse response = ((IOrganizationService)result.AsyncState).EndExecute(result);

OptionSetMetadata optionSetMetadata = ((EnumAttributeMetadata)(response.Results[0].Value)).OptionSet;

foreach (OptionMetadata option in optionSetMetadata.Options)


lblStageValues = (sb.AppendLine(option.Label.UserLocalizedLabel.Label)).ToString();



catch (Exception ex)






Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s