Hello All,
I have create a publisher and name is Employee and its prefix is emp.
I have try to get all custom fields using console application in which prefix emp and field is emp_fieldname but i am not getting tis type of data.
Please help me.
Hello All,
I have create a publisher and name is Employee and its prefix is emp.
I have try to get all custom fields using console application in which prefix emp and field is emp_fieldname but i am not getting tis type of data.
Please help me.
Hi vijay1234567,
I create a publisher and add a custom field whose prefix is emp on the Account table.
I tested with the following code and can get the data successfully.
using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Messages; using Microsoft.Xrm.Sdk.Metadata; using Microsoft.Xrm.Sdk.Query; using Microsoft.Xrm.Tooling.Connector; using System; using System.Linq; namespace ReteriveMetadata { class Program { static void Main(string[] args) { try { var connectionString = @"AuthType = Office365; Url = https://yourcrm.crm.dynamics.com/;Username=yourusername;Password=yourpassword"; CrmServiceClient client = new CrmServiceClient(connectionString); IOrganizationService service; service = (IOrganizationService)client.OrganizationWebProxyClient != null ? (IOrganizationService)client.OrganizationWebProxyClient : (IOrganizationService)client.OrganizationServiceProxy; const string ENTITY_TO_CHECK = "account"; // logical name var prefixesQuery = new QueryExpression("publisher") { ColumnSet = new ColumnSet("customizationprefix") }; var prefixesData = client.RetrieveMultiple(prefixesQuery).Entities ?.Select(e => e.GetAttributeValue("customizationprefix")); Console.WriteLine("Publisher prefixes:"); foreach (var pd in prefixesData) Console.WriteLine("> {0}", pd); var columnsQuery = new RetrieveEntityRequest { LogicalName = ENTITY_TO_CHECK, EntityFilters = EntityFilters.Attributes, RetrieveAsIfPublished = true }; var columnsData = (client.Execute(columnsQuery) as RetrieveEntityResponse)?.EntityMetadata?.Attributes ?.Where(col => prefixesData.Any(prefix => col.LogicalName.StartsWith("emp_"))) .OrderBy(col => col.LogicalName); Console.WriteLine("{0} custom fields: {1}", ENTITY_TO_CHECK, columnsData.Count()); foreach (var cd in columnsData) Console.WriteLine("> {0}", cd.LogicalName); Console.ReadLine(); } catch (Exception ex) { } } } }
Result:
You can have a try the above code.
Reference:
c# - How can recognize a custom field programmatically? - Stack Overflow
Hi,
Can you please share your code?
Please check code from below article to retrieve attribute metadata
André Arnaud de Cal...
293,001
Super User 2025 Season 1
Martin Dráb
231,837
Most Valuable Professional
nmaenpaa
101,156
Moderator