web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Error set Optionset from plugin

(0) ShareShare
ReportReport
Posted on by

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:

1830.Untitled.png

*This post is locked for comments

I have the same question (0)
  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Unfortunately your exception description doesn't give an answer what's wrong. Can you please be more specific providing full description of your error and exact code you use (because this one looks like example but not code from real system).

  • Community Member Profile Picture
    on at

    Hii andrii, I edited my question.

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Can you please add all the code (because it still doesn't look complete) and especially line where your exception occurs and provide full text of exception?

    Just FYI. My name is Andrii. Not andrii.

  • Suggested answer
    Goutham A Profile Picture
    2 on at

    yes. this above code should work. Alternatively you can try

    ent.Attributes.Add(“new_optionsetfield”, new Optionsetvalue(100000001));

    Also, please paste the entire error/See fiddler traces if you can find any hint of the WCF error thrown

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Try please doing following:

    surround line

    service.Create(rs);

    with try catch like:

    try

    {

    service.Create(rs);

    }

    catch(Exception ex)

    {

    Console.WriteLine(ex.Message);

    throw;

    }

    that will give you error message in your console application. Please post this message here.

  • Community Member Profile Picture
    on at

    Hi Andrii, I edited again the code. Everything is fine with my code, but start error when I tried to set Optionset field. When I remove those line. The code work fine

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Please show that new_systemsource attribute in CRM. It looks that it is boolean and not optionset.

  • Community Member Profile Picture
    on at

    Its show: Incorect type of attribute value System.boolean

  • Goutham A Profile Picture
    2 on at

    The error i see is "Incorrect type of attribute value System.Boolean". As Andrii suggested, please check the type of attribute and if it is option set please  check the type of option set. I think it is of bit type similar to isemailaddressapprovedbyo365admin OOb option set of systemuser entity

    <OptionSetType>bit</OptionSetType>

  • Community Member Profile Picture
    on at

    70725.Untitled.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans