locked
Set optionset value to empty RRS feed

  • Question

  • Hi,

    I would like to know how we can set an optionset value in a record to be empty using C# code.

    Thak you in advance

    Monday, April 30, 2012 12:51 PM

Answers

  • Hi,

    I am using early bound and I just found out that I should use the below syntax

    linqrecord.attributeName = new OptionSetValue(-1);

    Thank you for your answers

    • Marked as answer by ms_crm Monday, April 30, 2012 1:12 PM
    Monday, April 30, 2012 1:09 PM

All replies

  • Hi

    you can set option set using below code

    entity.Attributes["type"] = new OptionSetValue(1);

    if you want to set null value then you don't need to set value on that attribute.


    • Edited by _Vikram Monday, April 30, 2012 12:59 PM
    Monday, April 30, 2012 12:57 PM
  •  Hi

    To put an unassigned value , Set it null

    hth

    dkay


     if the response answered your question, please take a minute and mark the response as an answer.

     

    Monday, April 30, 2012 12:57 PM
  • Hi thank you for your reply.

    Actually what I need is to empty an optionset.

    I have a record where the optionset is filled, I need to empty it.

    How is it possible?

    Monday, April 30, 2012 12:59 PM
  • Hi,

    I am using early bound and I just found out that I should use the below syntax

    linqrecord.attributeName = new OptionSetValue(-1);

    Thank you for your answers

    • Marked as answer by ms_crm Monday, April 30, 2012 1:12 PM
    Monday, April 30, 2012 1:09 PM