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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Unable to cast object of type 'Microsoft.Xrm.Sdk.OptionSetValue' to type 'System.IConvertible'

(0) ShareShare
ReportReport
Posted on by

Hi 

I am trying to compare the option set value in my  class. but I am getting this error "{"Unable to cast object of type 'Microsoft.Xrm.Sdk.OptionSetValue' to type 'System.IConvertible'."}." can any one please suggest to resolve this problem.please it's very urgent.

here is my code

if(new OptionSetValue(Convert.ToInt32(sa.Attributes["isr_typeofdegree"])).Value== new OptionSetValue(Convert.ToInt32(905080000)).Value)
{

//logic

}

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Daniel Wikell Profile Picture
    2,360 on at

    You are trying to convert sa.Attributes["isr_typeofdegree"] into an int32 but this is not something that can be casted this way. isr_typeofdegree seems to be of type "OptionSetValue" and thus you want to use the Value of it to retrieve the int.

    There's no need to create more wrappers around just the int.

    Your code would be better off doing something like:

    if(((OptionSetValue)sa.Attributes["isr_typeofdegree"]).Value == 905080000) {

    //logic

    }

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Varsha deshpande Profile Picture

Varsha deshpande 5

#2
JS-09031509-0 Profile Picture

JS-09031509-0 3

#3
Ciprian  P Profile Picture

Ciprian P 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans