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