1

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

Dijkgraaf
  • 9,324
  • 15
  • 34
  • 48
isir
  • 13
  • 2
  • Yes, a known issue with BizTalk 2013 and up, do what Gary suggested and treat them as strings – Dijkgraaf Sep 16 '16 at 21:09
  • Hold on, as I mentioned in your other thread, we need to know the Type of the source node. Yes, it can make a difference. – Johns-305 Sep 17 '16 at 12:27
  • See Known issues in BizTalk Server 2013 https://support.microsoft.com/en-gb/kb/2954101 Known Issues in XSLCompiledTransform – Dijkgraaf Sep 17 '16 at 19:34

2 Answers2

0

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.

  • Thanks Gary will update the code in my functoid and test – isir Sep 16 '16 at 06:43
  • Thanks Gary i have updated my code as to what you have provided and it works thanks for the assistance – isir Sep 20 '16 at 08:28
  • @isir Glad I could help. Please don't forget to accept this answer in stackoverflow, if it did help you. –  Sep 21 '16 at 12:08
0

If it is indeed xs:boolean, you can do:

public MyFunctoid(string MyParam)
{
     if(MyParam == "true")
     {
          return "It was true!";
     }
     return "It was false!";
}

This is because the value of MyParam can be one of only 3 things, 'true', 'false' or ''.  You only need to test for 'true'.  This is one case where a [Try]Parse is not necessary.

Johns-305
  • 10,704
  • 10
  • 21