locked
Obtaining the value of an object of a CrmBoolean type RRS feed

  • 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 Barness
    Thursday, 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
    Thursday, March 3, 2011 9:48 PM
    Moderator
  • 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 Barness
    Thursday, 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

    Thursday, March 3, 2011 10:28 PM
    Moderator
  • 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 Miley
    Thursday, March 3, 2011 10:52 PM
    Moderator
  • 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 Barness
    Friday, March 4, 2011 2:01 PM