Incorrect attribute value type System.Int32

Yanıt Incorrect attribute value type System.Int32

  • 31 Mayıs 2012 Perşembe 07:31
     
      Kod İçerir

    Hi,

    I have an entity with an OptionSet field.  I am trying to insert a record in the entity via a Plug-in.  I use an enum to represent all my option sets.

    The line below throws the error "

    Incorrect attribute value type System.Int32".  Any ideas would be greatly appreciated.

    dEntity.Attributes.Add("d_orderstatus"newOptionSetValue((int)OrderStatus.Approved));

    service.Create(dEntity)

     

Tüm Yanıtlar

  • 31 Mayıs 2012 Perşembe 08:00
     
     

    Hi,

    Check if the sent int-value exists in the option set on the crm system - if the value doesn't equal one of the options the service can't create the data.

    Greets,

    Andreas


    Andreas Buchinger
    Microsoft Dynamics Certified Technology Specialist
    MCPD: SharePoint Developer 2010

  • 31 Mayıs 2012 Perşembe 15:04
     
     
    I did and the value exists in the option set on the crm system.  Still no luck.
  • 31 Mayıs 2012 Perşembe 15:16
     
     

    Hi,

    I tried the code above on my test system and it works fine...

    Have you tried to call the method with the enum value itself ( dEntity.Attributes.Add("d_orderstatus", new OptionSetValue(1) )? Does the error occure in code or on the crm server in tracing?

    Greets,

    Andreas


    Andreas Buchinger
    Microsoft Dynamics Certified Technology Specialist
    MCPD: SharePoint Developer 2010

  • 01 Haziran 2012 Cuma 07:33
     
     Yanıt

    Hi Andreas,

    This is quite bizzare.  That didn't work either.  The error occurs in tracing.

    • Yanıt Olarak İşaretleyen fifo123 03 Haziran 2012 Pazar 18:32
    •  
  • 01 Haziran 2012 Cuma 11:08
     
     Önerilen Yanıt

    Hi,

    That's really quite bizzare!

    Another point that could cause the problem: Are you sure that your customizations are all published? The code in the plugin can only interact with published customizations...

    Greets,

    Andreas


    Andreas Buchinger
    Microsoft Dynamics Certified Technology Specialist
    MCPD: SharePoint Developer 2010

  • 03 Haziran 2012 Pazar 18:31
     
     

    Andreas,

    I dropped and re-created the entity and it works now.  Not sure why it didn't in the first place...just glad it's working.  Thanks for all the help.

  • 04 Haziran 2012 Pazartesi 07:22
     
     

    Hi,

    I'm glad that it works now - it would be nice if you also mark one of mine hints as possible answer...

    Thanks and Greets,

    Andreas


    Andreas Buchinger
    Microsoft Dynamics Certified Technology Specialist
    MCPD: SharePoint Developer 2010