Hello All,
I try to create the "Auto Number " field from C# Console while Execute the "Create Attribute Request ", I am getting the Following Issue .
Type 'AutoNumber.StringAttributeMetadata' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute
Class Program
{
static OrganizationServiceProxy _organizationProxy = null; static void Main(string[] args) { CreateCRMProxy(); CreateAutoNumberAttributeProxy(_organizationProxy, "gitta_employee", "gitta_empid", "gitta_Empid", "EMP-{SEQNUM:4}", "Employee AUTO ID", "Employee AUTO Number Description"); //if (ConnectToCRM_Method3()) //{ // Console.WriteLine("CRM Connection Established.."); // CreateAutoNumberAttribute(_orgService, "gitta_employee", "gitta_empid", "gitta_empid", "EMP-{SEQNUM:4}", "Employee AUTO ID", "Employee AUTO Number Description"); //} //else //{ // Console.WriteLine("CRM Connection Established Failed .."); //} Console.ReadLine(); }
}
public static void CreateAutoNumberAttributeProxy(OrganizationServiceProxy _organizationProxy, string EntityName, String LogicalName, string SchemaName, string AutonumberFormat, string DisplayName, string DisplayDescription) { CreateAttributeRequest employeeIdAutoNumber = new CreateAttributeRequest { EntityName = EntityName, Attribute = new StringAttributeMetadata { AutoNumberFormat = "EMP-{SEQNUM:5}", LogicalName = LogicalName, SchemaName = SchemaName, RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None), DisplayName = new Label(DisplayName, 1033), Description = new Label(DisplayDescription, 1033), } }; _organizationProxy.Execute(employeeIdAutoNumber);
}
public static void CreateCRMProxy() { string orgServiceUrl = ConfigurationManager.AppSettings["Url"]; string userName = ConfigurationManager.AppSettings["username"]; string password = ConfigurationManager.AppSettings["password"]; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; ClientCredentials clientCredentials = new ClientCredentials(); clientCredentials.UserName.UserName = userName; clientCredentials.UserName.Password = password; // Set security protocol to TLS 1.2 for version 9.0 of Customer Engagement Platform ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; _organizationProxy= new OrganizationServiceProxy(new Uri("">gitta9.crm.dynamics.com/.../Organization.svc"), null, clientCredentials, null); }
Type 'AutoNumber.StringAttributeMetadata' cannot be serialized. Consider marking it with the DataContractAttr
ibute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute
I am unable to found what is Root Cause.
*This post is locked for comments