locked
Stuck on an IF statement RRS feed

  • Question

  • If this IF statement is in the code, it never fires off. And I'm not really sure why, it's starting to drive me crazy. So I Thought I'd ask.

    Here is how I am getting the data:

    EntityReference roleid = (EntityReference)postImageEntity.Attributes["record1roleid"]);
    string role = roleid.Id.ToString();

    I've done it in this fashion to verify the actual data that is being passed, so that I could create the IF statement. But I have tried both of the following IF's.. and neither of them fires off the rest of the code. I have verified that there is data in the "record1roleid" (This is all nested in an IF statement where it won't fire off anything unless there is data there).

    and I have verified that the string that comes back is valid.

    Here is my IF statement: (note.. I am not using them both. I have tried them both, individually, unsuccessfully.)

    if (role.Equals("1780F6B1-5BFC-E111-B820-005056BF0011"))
                    {
    if (role == "1780F6B1-5BFC-E111-B820-005056BF0011")
    {
    Again, I have verified that the "1780..." is what is being captured, and that it does exist.
    (I have verified the data by simply having it write to a text field on a record)
    any help here would be greatly appreciated.


    Daniel


    • Edited by I am Oop Thursday, February 20, 2014 8:31 PM
    Thursday, February 20, 2014 8:00 PM

Answers

  • Sorry if you have already done this but have you tried roleid.Id == new Guid("my-string")?
    • Marked as answer by I am Oop Thursday, February 20, 2014 9:47 PM
    Thursday, February 20, 2014 9:39 PM

All replies

  • Sorry if you have already done this but have you tried roleid.Id == new Guid("my-string")?
    • Marked as answer by I am Oop Thursday, February 20, 2014 9:47 PM
    Thursday, February 20, 2014 9:39 PM
  • I tried something like that, but I think my syntax may have been off. I'll give it a shot. If it works I'll let you know and mark your post as the answer. Thanks for helping.

    Daniel

    Thursday, February 20, 2014 9:44 PM
  • We have a winner! Thank you very much. That did it. And I looked and yes, when I tried that my syntax was off and so I moved on to the next tries.

    Much obliged. Have a great day.


    Daniel

    Thursday, February 20, 2014 9:47 PM