BizTalk expressions: null or empty string?

Writing conditions containing distinguished fields in BizTalk 2004 orchestration (XLANG) can be very confusing… If an element is not supplied in the XML document and I write it to the debug log, it looks like it contains an empty string: 

System.Diagnostics.Debug.WriteLine(RegisterCustomerAccountIncoming.ExistingAccount.SystemName);

where SystemName is a distinguished field writes an empty string to the debug log, but this comparison fails:

RegisterCustomerAccountIncoming.ExistingAccount.SystemName == ""

because it really contains null! So you should really check for both null and empty string just to be sure:

RegisterCustomerAccountIncoming.ExistingAccount.SystemName == null || RegisterCustomerAccountIncoming.ExistingAccount.SystemName == ""

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s