Search code examples
c#biztalkbiztalk-2013r2

My BizTalk functoid returns true value regardless of the boolean being passed


I am having an issue on my BizTalk application

I have customized the functoid to change value based on the boolean it has received her is the code

 public string GetBoolMark(bool param1)
        {
            string returnValue = "0";
            if (param1 == true )
            {
                returnValue = "1";
            }
            return returnValue;
        }

I am having an issue that the value always returns the true value. I am using BizTalk server 2013 R2


Solution

  • Change the type of param1 from bool to string. Parse it carefully inside you function to a boolean, and use that boolean to decide what to return.

     public string GetBoolMark(string param1)
        {
            bool condition;
            string returnValue = "0";
    
            if (bool.TryParse(param1, out condition) && condition)
            {
                returnValue = "1";
            }
            return returnValue;
        }
    

    When using the inline C# in a scripting functoid, I always find it easier to assume all parameters are strings. If you use other type, some implicit parsing will be performed for you. I'd rather perform the parsing myself explicitly because I don't know exactly how the implicit parsing works.