Answered by:
Obtaining the value of an object of a CrmBoolean type

Question
-
I have a DynamicEntity that one of its fields is of CrmBoolean type. I need to display the value (either 'true' or 'false'). How would this be done?
example:
CrmBoolean myValue;
myvalue = myentity[somename].Value; (??? Value is not valid in this case)
I want myvalue to have either 'true' or 'false' whichever the value of myentity[somename] is.
Baruch BarnessThursday, March 3, 2011 9:37 PM
Answers
-
I got it:
myvalue = (CrmBoolean)myentity[somename]).Value;
Baruch Barness- Marked as answer by Barucho1 Thursday, March 3, 2011 10:21 PM
Thursday, March 3, 2011 10:21 PM
All replies
-
So Basically you need to set
myValue.Value = true; // or false
//
CrmBoolean boolean = new CrmBoolean(); boolean.Value = true;
From: http://msdn.microsoft.com/en-us/library/aa613519.aspx
Jamie Miley- Proposed as answer by Jamie MileyModerator Thursday, March 3, 2011 9:49 PM
Thursday, March 3, 2011 9:48 PMModerator -
No!!
Your solution is hardcoding the value of 'myvalue' to true (or false)
What I need is set the value of 'myvalue' object to whichever the value of myentity[somename] value is.
That is:
myvalue = (the value of) myentity[somename]
rather then
myvalue = true;
Hope this is clearer now.
Baruch BarnessThursday, March 3, 2011 10:16 PM -
I got it:
myvalue = (CrmBoolean)myentity[somename]).Value;
Baruch Barness- Marked as answer by Barucho1 Thursday, March 3, 2011 10:21 PM
Thursday, March 3, 2011 10:21 PM -
he got it from me :P
My blog : http://mscrmtools.blogspot.com
All my tools for Dynamics CRM 4.0 on my dedicated site: MSCRMTools Repository
Upgraded tools for Dynamics CRM 2011!
View Layout Replicator for Microsoft Dynamics CRM 2011
Searchable Property Updater for Microsoft Dynamics CRM 2011Thursday, March 3, 2011 10:28 PMModerator -
myvalue.Value = true; was really getting to a lot of the crux of his issue. I was hardcoding to illustrate.
I was showing him that .Value had to be added to his CrmBoolean to assign the value of true or false (as he stated). I also pointed to the sdk resource that shows how to work with CrmBoolean.
His casting to a CrmBoolean just handled it from the other end of the equation. As he said he wanted to assign either true or false. If he used MyValue.Value he could have done so.
So I will argue that he got it from me :)
:P I'll be nice and vote you as helpful though.
Jamie MileyThursday, March 3, 2011 10:52 PMModerator -
Although Jamie's intentions may have been noble (and techincally correct), P's answer to my other post (related to a simmilar issue) was right on the money.
Baruch BarnessFriday, March 4, 2011 2:01 PM