Q:

Biztalk mapping inline script global not updated

Good afternoon,
The problem:
I'm trying to count output nodes in a biztalk mapping.
I don't want to use the record count functoid or a xslt transformation since there are a lot of conditions that determine if the node is generated.
What I tried:
I created a script functoid and declared a global variable (in C#).
// global to save count
public int E1_Record_Count = 0;

I created a script functoid to output the global variable and tied it to my output node:
public string E1_Records()
{
  return E1_Record_Count.ToString();
}

I created a script functoid and that is connected to the logical functoid that controls if a node is produced. This script counts the number of nodes created:
public void IncrementE1Count( string isOutput )
{
  try
  {
     if ( System.Convert.ToBoolean( isOutput )  )
      ++E1_Record_Count;
  }
  catch
  {
  }
}

What doesn't work:
I always get zero as result. I've changed the global declaration and the output changes so the global seems to be declared, initialized and output correctly. Creating a second declaration for the global throws an error so there's only one global instance of the variable.
I commented out everything but the increment line in the script to change the global. This makes me think it's never being executed. This script functoid is tied to the same logical functoid that controls the output nodes (which I do get).
Any ideas what's going wrong?
I'm using Biztalk Server 2010.

A:

I found it was simplest to create an orchestration and use two sequential transformations to count the nodes.

