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)

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)
  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    did you include this attribute when you select the record?

  • sdnd2000 Profile Picture
    2,510 on at

    I am getting this value from somewhere else

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    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.

  • Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    Are you possibly missing the prefix from the attribute name?

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

  • Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

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

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