// ReSharper disable once UnusedParameter.Local private AttributeMetadata CloneAttributes(EntityNameAttributeMetadata att) { return new EntityNameAttributeMetadata(); }
// ReSharper disable once UnusedParameter.Local private AttributeMetadata CloneAttributes(EntityNameAttributeMetadata att) { return(new EntityNameAttributeMetadata()); }
public static DataTable GetDropDownOptions(string entityName, string attributeName) { OrganizationServiceProxy serviceProxy = CrmHelper.Connect(); DataTable options = new DataTable(); options.Columns.Add("Value"); options.Columns.Add("Name"); RetrieveAttributeRequest attributeRequest = new RetrieveAttributeRequest { EntityLogicalName = entityName, LogicalName = attributeName }; RetrieveAttributeResponse attributeResponse = (RetrieveAttributeResponse)serviceProxy.Execute(attributeRequest); // Handle Picklist options if (attributeResponse.AttributeMetadata.AttributeType == AttributeTypeCode.Picklist) { PicklistAttributeMetadata picklist = (PicklistAttributeMetadata)attributeResponse.AttributeMetadata; foreach (OptionMetadata option in picklist.OptionSet.Options) { DataRow optionDataRow = options.NewRow(); optionDataRow["Value"] = option.Value.Value; optionDataRow["Name"] = option.Label.UserLocalizedLabel.Label; options.Rows.Add(optionDataRow); } } // Handle Status options (Active State only) else if (attributeResponse.AttributeMetadata.AttributeType == AttributeTypeCode.Status) { StatusAttributeMetadata status = (StatusAttributeMetadata)attributeResponse.AttributeMetadata; foreach (StatusOptionMetadata option in status.OptionSet.Options) { //if (option.State.Value == 0) // Active State //{ DataRow optionDataRow = options.NewRow(); optionDataRow["Value"] = option.Value.Value; optionDataRow["Name"] = option.Label.UserLocalizedLabel.Label; options.Rows.Add(optionDataRow); //} } } // Handle Status options (Active State only) else if (attributeResponse.AttributeMetadata.AttributeType == AttributeTypeCode.EntityName) { EntityNameAttributeMetadata name = (EntityNameAttributeMetadata)attributeResponse.AttributeMetadata; foreach (OptionMetadata option in name.OptionSet.Options) { DataRow optionDataRow = options.NewRow(); optionDataRow["Value"] = option.Value.Value; optionDataRow["Name"] = option.Label.UserLocalizedLabel.Label; options.Rows.Add(optionDataRow); } } return(options); }