Aşağıdaki metoda optionset in adını ve texti alınacak değerin value sunu göndermek yeterlidir.
public string GetOptionsetText(Entity entity, IOrganizationService service, string optionsetName, int optionsetValue)
{
string optionsetSelectedText = string.Empty;
try
{
RetrieveOptionSetRequest retrieveOptionSetRequest =new RetrieveOptionSetRequest{
Name = optionsetName
};
// Execute the request.
RetrieveOptionSetResponse retrieveOptionSetResponse =(RetrieveOptionSetResponse)service.Execute(retrieveOptionSetRequest);
// Access the retrieved OptionSetMetadata.
OptionSetMetadata retrievedOptionSetMetadata = (OptionSetMetadata)retrieveOptionSetResponse.OptionSetMetadata;
// Get the current options list for the retrieved attribute.
OptionMetadata[] optionList = retrievedOptionSetMetadata.Options.ToArray();
foreach (OptionMetadata optionMetadata in optionList)
{
if (optionMetadata.Value == optionsetValue)
{
optionsetSelectedText = optionMetadata.Label.UserLocalizedLabel.Label.ToString();
break;
}
}
}
catch (Exception ex)
{
throw ex;
}
return optionsetSelectedText;
}
Hiç yorum yok:
Yorum Gönder