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

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

Hi,

I am working on Dynamics 365 plugin and while taking the value of OptionSetValue it is throwing following error:

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

My code is:

string new_fieldstatus = (string)entity["new_fieldstatus"];

But it is throwing error.

What is the solution?

Thanks

View Answers

May 29, 2021 at 6:58 AM

Hi,

Following code is working for me:

string newfieldstatus = ((OptionSetValue)entity.Attributes["newfieldstatus"]).Value.ToString();

You can use this code as its working for me.

This code converts the value of OptionSet into string.

Thanks


May 29, 2021 at 6:58 AM

Hi,

Code is:

string newfieldstatus = ((OptionSetValue)entity.Attributes["newfieldstatus"]).Value.ToString();

Thanks









Related Tutorials/Questions & Answers:
Unable to cast object of type 'Microsoft.Xrm.Sdk.OptionSetValue' to type 'System.String'
Unable to cast object of type 'Microsoft.Xrm.Sdk.OptionSetValue' to type... the value of OptionSetValue it is throwing following error: Unable to cast object of type 'Microsoft.Xrm.Sdk.OptionSetValue' to type 'System.String
UIButton sender type cast
UIButton sender type cast  Hi, I want to type cast sender object... very easy to typecast the sender object into UIButton. Please see the following...; HI, Its very easy to typecast the sender object into UIButton. Please see
Advertisements
Reference type Vs Object type. - Java Beginners
Reference type Vs Object type.  Can anyone explain the exact... or object type variable which may reference a Book object or an object of any... 'Manager' would the OBJECT TYPE Moderators, please correct me if I'm wrong
Method is undefined for the type Object(org.apache.jasper.JasperException)
Method is undefined for the type Object(org.apache.jasper.JasperException) ... getPracticeRevenueCode() is undefined for the type Object...: org.apache.jasper.JasperException: Unable
object retun type - Java Beginners
object retun type  Hi, i have to create a method which should have return type of object . The object should contain 'list of filenames' array and a boolean field 'isVal'. Can anybody help
AttributeError: type object 'object' has no attribute 'dtype'
AttributeError: type object 'object' has no attribute 'dtype'  Hi, I am using pandas in one of my Python program. But its throwing following error... AttributeError: type object 'object' has no attribute 'dtype' How to resolve
AttributeError: type object 'object' has no attribute 'dtype'
AttributeError: type object 'object' has no attribute 'dtype'  Hi, I am using pandas in one of my Python program. But its throwing following error... AttributeError: type object 'object' has no attribute 'dtype' How to resolve
Type casting
Type casting  how to type cast a string value to byte array
Java type casting
Java type casting  Can a Byte object be cast to a double value
Does the object type known during compilation in Java?.
Does the object type known during compilation in Java?.  class A { } class B extends class A { } class checkType { public static void main(String[] args) { A ObjA = new B();/// Here ObjA is of type A--> this fact
Convert an Integer type object to a String object
Convert an Integer type object to a String object   ... the Integer type object to a String object using the Integer.toBinaryString...; Create a class "NumberFormats" where an integer type object is converted
type casting
; } how to type cast object type to entity type...type casting  <--bean class-->method calllist is of object type... List (object type) <Object> totalList(int pi){ (adsbygoogle
I retrieve a String or other object type without creating a new object each time.
I retrieve a String or other object type without creating a new object each time.  How can I retrieve a String or other object type without creating a new object each time
type casting
type casting  what is type casting
Class Cast Exception Example in java
exception in java. The class cast exception is a converting one data type into another data type. A Class cast exception is a thrown by java. In this example... vector.ADS_TO_REPLACE_1 Object obj = vector.add( a ):-Adds an integer type
type mismatch
type mismatch  Statement s= con.createStatement(); this line gives error of "type mismatch" I am using eclips nd new to servlet nd JDBC, Please help me, Thank you
data type
data type  which data type is used to store video file in mysql databse
type casting
type casting  int n=20; n=sizeof((char)(float)n); what is n value
Type casting in java
is nothing but  casting one object type to another object type. In simple... a double type cast to int type    Reference type casting : In java type casting is to cast one type, a class or interface to another type i.e. another
Casting (Type Conversion)
casting. In java one object reference can be type cast into another object reference... object can reference to a reference variable of the type Object, as Object class... then this type of casting is termed as upcasting. Upcasting does not require a cast
PHP Object Type
PHP Object: Class, and Object are one of the most important feature of OOP. Object is the instance of a class, to create an object we use new keyword. In PHP we can convert any value to an object of a predefined class called stdClass
data type
Single Double Decimal Char Boolean Date String Object
PHP Type Hinting
a value into objects of a class or to an array. Type Hints only supports object... object of any class type or array type. Example : <?php class One...PHP Type Hinting Function: Type hinting is a special type of function which
Java Type Casting - Java Beginners
Java Type Casting  what is object type casting? give some example with related
fastest type of JDBC driver
fastest type of JDBC driver  What is the fastest type of JDBC driver
Document Type Definition
Document Type Definition  What is Document Type Definition
coding for re-type password
coding for re-type password  coding for re-type password
Date type typecasting - Java Beginners
Date type typecasting  Can i type cast Date object of java.util.* to java.sql.* Date Object? if so how? Refer to the following url http... the system what format the date is in. To do this you use a DateFormat object
Java type casting
Java type casting  What is Downcasting
What is mime type in HTML
What is mime type in HTML  what is mime type in html? is it different in new HTML5
What is mime type in HTML
What is mime type in HTML  what is mime type in html? is it different in new HTML5
eraser type generics in java
eraser type generics in java  Explain eraser type generics in java with example
type casting purpose
type casting purpose  what is type casting , could u explain with practical example
ModuleNotFoundError: No module named 'type'
ModuleNotFoundError: No module named 'type'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'type' How to remove the ModuleNotFoundError: No module named 'type' error
ModuleNotFoundError: No module named 'type'
ModuleNotFoundError: No module named 'type'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'type' How to remove the ModuleNotFoundError: No module named 'type' error
ModuleNotFoundError: No module named 'type'
ModuleNotFoundError: No module named 'type'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'type' How to remove the ModuleNotFoundError: No module named 'type' error
ModuleNotFoundError: No module named 'type'
ModuleNotFoundError: No module named 'type'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'type' How to remove the ModuleNotFoundError: No module named 'type' error
Fastest type of JDBC Driver
Fastest type of JDBC Driver  hello, What is the fastest type of JDBC driver?   hii,ADS_TO_REPLACE_1 Type 4 is the fastest JDBC driver
Type Comparison Operator
an object to a specified class type. The instanceof operator is defined..., if the object or array is an instance of the specified type; otherwise it returns... Type Comparison Operator   
type 4 jdbc driver
type 4 jdbc driver   i read in this site that type 4 jdbc driver is the fastest one so used it to connect with the database.......but not tried another drivers,....can u specifically answer me why type 4 is the fastest one
elasticsearch search by type
elasticsearch search by type  Hi, How to perform search by type... { "query": { "type" : { "value" : "doc" } } } Above query will search all the data with the type "doc". Thanks
SERIAL data type
SERIAL data type   hello, What is SERIAL data type in MySQL?   hii,ADS_TO_REPLACE_1 SERIAL is an alias for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE
incomplete pointer type NSMutableDictionary
incomplete pointer type NSMutableDictionary  My iphone app is throwing the "incomplete pointer type NSMutableDictionary" issue on running the iphone app. What is this issue and how can i remove it. NSMutableDictionary *dict
methods type - Java Beginners
methods type in Java  Give me an example programs of methods types in Java
alter data type
alter data type  alter data type of subName column for subject table to varchar(40
Type casting the returned value of a method.
Type casting the returned value of a method.  Hi, How do you type cast the returned value of a method so that you can avoid creating a temporary...) will be of type OnOffButton. I want to avoid: OnOffButton btn = (OnOffButton
incompatble type error
incompatble type error  class ArithmeticExceptiontest { public static void main(String args[]) { int num1 = 0; int num2=10...); } } } trows incampatble type error
type 4 drivers - JDBC
type 4 drivers  Hi! What is the syntax for Type - 4 drivers. give me any sample code. Thanks in advance..  Hi Friend, Please visit the following link: http://www.roseindia.net/jdbc/jdbc-driver-and-its
HSSFCell to String type conversion
HSSFCell to String type conversion  Hello, Can anyone help me convert HSSFCell type to string. There is a solution in the following URL, but the method getWorkbook() is not defined for the class HSSFCell. Thanks in advance
Introduction to Type conversion in Struts
or a process in which data is converted into one object type to other object type... object and collections. To use type conversion mechanism you need to do... into a object. An example of type conversion is given in the next section

Ads