How to get global option set values for dynamics crm with c#

This method maybe helping for you


public static List<GlobalOptionSetModel> GetGlobalOptionSetList(string globalOptionSetName, IOrganizationService service)

{

List<GlobalOptionSetModel> result = new List<GlobalOptionSetModel>();

RetrieveOptionSetRequest retrieveOptionSetRequest = new RetrieveOptionSetRequest { Name = globalOptionSetName };

RetrieveOptionSetResponse retrieveOptionSetResponse = (RetrieveOptionSetResponse)service.Execute(retrieveOptionSetRequest);

OptionSetMetadata optionSetMetadata = (OptionSetMetadata)retrieveOptionSetResponse.OptionSetMetadata;

List<OptionMetadata> optionList = optionSetMetadata.Options.ToList();

result = optionList.ConvertAll(z => new GlobalOptionSetModel { Label = z.Label.UserLocalizedLabel.Label, Value = z.Value.ToString(), LanguageCode = z.Label.UserLocalizedLabel.LanguageCode.ToString() });

return result;
}

public class GlobalOptionSetModel
{
public String LanguageCode { get; set; }
public String Value { get; set; }
public String Label { get; set; }
}

 

Advertisements

#csharp-global-option-set, #get-global-option-set-values, #ms-crm-global-option-set-values