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)

How to set Null or Empty to optionset value using c#.

(0) ShareShare
ReportReport
Posted on by 6

Hello All Experts,

Can anyone help me in doing this.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Gopalan Bhuvanesh Profile Picture
    11,401 on at

    Hi

    Set null

    Example:

    account["customertypecode"] = null;

    Refer the following:

    community.dynamics.com/.../186822

  • Suggested answer
    joman Profile Picture
    617 on at

    Entity _entity = new Entity("Your_Name");

    _entity.Id = someId;

    if(_entity.Contains("Your_OptionSetValue_Attribute"){

    _entity["Your_OptionSetValue_Attribute"] = null;

    } else {

    _entity.attributes.add("Your_OptionSetValue_Attribute", null);

    }

    service.update(_entity);

  • EmployeeOcta Profile Picture
    6 on at

    Hello Joman,

    if the above is correct then what's wrong in below.

    Entity opportunityOne = new Entity("opportunity");

                                   opportunityOne.Id = ((Microsoft.Xrm.Sdk.EntityReference)(opportunitytypes[0].Attributes["new_opportunityid"])).Id;

                                   opportunityOne.Attributes.Add("new_opportunitytype", null);

                                   service.Update(opportunityOne);

    is there anything wrong in above.

  • joman Profile Picture
    617 on at

    looks good. Is Something wrong?

  • Suggested answer
    Gopalan Bhuvanesh Profile Picture
    11,401 on at

    Hi

    1. Check whether you are getting the GUID of the record.

    2. Alternatively, just use opportunityOne.Attributes["new_opportunitytype"] =  null;

  • EmployeeOcta Profile Picture
    6 on at

    Hello Gopalan,

    Yes you are correct ,

    the guid was missing. and above code which i have put is correct.

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