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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

c# get selected option set text

(0) ShareShare
ReportReport
Posted on by 2,510

Hi, I am trying to get the selected item text from an option set. I got this error:  "The given key was not present in the dictionary"

contact.FormattedValues["registrationcategory"].ToString()


*This post is locked for comments

I have the same question (0)
  • Alex Fun Wei Jie Profile Picture
    33,626 on at
    RE: c# get selected option set text

    Hi,

    Aric could be right also. just change the prefix in the provided code if he is right.

  • Aric Levin - MVP Profile Picture
    30,190 Moderator on at
    RE: c# get selected option set text

    Are you possibly missing the prefix from the attribute name?

    contact.FormattedValues["new_registrationcategory"].ToString()

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    33,626 on at
    RE: c# get selected option set text

    Hi,

    i assumed you include this attribute when you select the record.

    Next, check is the optionset value contain data for the selected record?

    if no, you might need to put a checking

    example :

     if (contact.Attributes.Contains("registrationcategory"))

    {

      optionset = contact.FormattedValues["registrationcategory"].ToString();

    }

    Reason :

    if the attribute does not contain data, when you select the record, although you included the attribute, but you will not see the attribute.

  • sdnd2000 Profile Picture
    2,510 on at
    RE: c# get selected option set text

    I am getting this value from somewhere else

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    33,626 on at
    RE: c# get selected option set text

    Hi,

    did you include this attribute when you select the record?

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#2
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans