Why I am receiving this :
Failed to injecting the data because :
System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: (Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault).
when tryng to set optionsetvalue.
I use this to set optionset field:
entity["new_optionsetfield"] = new Optionsetvalue(100000001);
I m sure there is no mistake within my code, the value number is correct. Also the field name is correct too.
EDITED:
The error come when I tried to set optionset value during integrating data from sql database. This optionset field also used for workflow in CRM system. Here is my code:
for (int i = 0; i < dt.Rows.Count; i++) { try { Entity rs = new Entity("new_troubleticket"); rs["new_systemsource"] = new OptionSetValue(100000001); Guid ticketid = new Guid(dt.Rows[i][0].ToString()); rs.Id = ticketid; //FIRSTNAME if (!string.IsNullOrEmpty(dt.Rows[i][1].ToString())) { rs["new_subject"] = dt.Rows[i][1].ToString(); } else { rs["new_subject"] = null; } service.Create(rs); } catch (Exception ex) { logger.Info("Exeception Number - 2: Failed to injecting the data because : ", ex); } } } } catch (Exception excep) { Console.WriteLine("Failed to insert data !!"+ excep); }
The other field value I take from sql database, but for the optionset I set it manual.
This is not a plugin, but a console application. I use log4net to see the error log. Everything is fine before I add this Optionset field line
This is the error
2016-08-19 16:47:14,562 [1] INFO CRMConsole.Program - Process Number - 1 : is running ... 2016-08-19 16:47:14,624 [1] INFO CRMConsole.Program - Process Number - 2 : Initialize to connecting to CRM 2016 Server 2016-08-19 16:47:15,046 [1] INFO CRMConsole.Program - Process Number - 3 : Validating credential to connecting to CRM 2016 Server successfully executed 2016-08-19 16:47:15,046 [1] INFO CRMConsole.Program - Process Number - 4 : Initialize to connecting to Database SQL Server 2016-08-19 16:47:18,172 [1] INFO CRMConsole.Program - Process Number - 5 : Succesfully connected to SQL Server Database 2016-08-19 16:47:18,172 [1] INFO CRMConsole.Program - Process Number - 6 : Starting to proccess the data batch.. 2016-08-19 16:47:21,939 [1] INFO CRMConsole.Program - Exeception Number - 2: Failed to injecting the data because : System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: Incorrect type of attribute value System.Boolean (Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault). 2016-08-19 16:47:22,018 [1] INFO CRMConsole.Program - Exeception Number - 2: Failed to injecting the data because : System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: Incorrect type of attribute value System.Boolean (Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault). 2016-08-19 16:47:22,049 [1] INFO CRMConsole.Program - Exeception Number - 2: Failed to injecting the data because : System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: Incorrect type of attribute value System.Boolean (Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault). 2016-08-19 16:47:22,096 [1] INFO CRMConsole.Program - Exeception Number - 2: Failed to injecting the data because : System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: Incorrect type of attribute value System.Boolean (Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault). 2016-08-19 16:47:22,127 [1] INFO CRMConsole.Program - Exeception Number - 2: Failed to injecting the data because : System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: Incorrect type of attribute value System.Boolean (Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault). 2016-08-19 16:47:22,174 [1] INFO CRMConsole.Program - Exeception Number - 2: Failed to injecting the data because : System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: Incorrect type of attribute value System.Boolean (Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault). 2016-08-19 16:47:22,205 [1] INFO CRMConsole.Program - Exeception Number - 2: Failed to injecting the data because : System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: Incorrect type of attribute value System.Boolean (Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault). 2016-08-19 16:47:22,205
FIELD PIC: