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

Ads
 

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

Ads









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' My code
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
Advertisements
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
type casting
List (object type) <Object> totalList(int pi){ try{ Query q...){ return null; } how to type cast object type to entity type...type casting  <--bean class-->method calllist is of object type
type casting
type casting  what is type casting
Casting (Type Conversion)
casting. In java one object reference can be type cast into another object reference... reference to a reference variable of the type Object, as Object class comes at the top... Casting (Type Conversion)      
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. Object obj = vector.add( a ):-Adds an integer type to the vector and stores
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
data type
Single Double Decimal Char Boolean Date String Object
coding for re-type password
coding for re-type password  coding for re-type password
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
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
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
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
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... parameters value and converts into a object. An example of type conversion
the array list contains similar type of elements or disimilar type of elements
the array list contains similar type of elements or disimilar type of elements  the array list contains similar type of elements or disimilar type of elements
The type ServiceRegistryBuilder is deprecated
The type ServiceRegistryBuilder is deprecated  I am trying to Create the SessionFactory in Hibernate using following code: Configuration...(serviceRegistry); It's giving the following error: The type ServiceRegistryBuilder
Enum data type
Enum data type  How can we use enum data type in java program?  ... data type. Here we have defined Fruits as enum type by using the enum keyword. Now... data type. Here we have defined Fruits as enum type by using the enum keyword. Now

Ads