You didn't say which QuickFIX port you are using (e.g. the original QF for C++, QF/J for Java, QF/n for C#).
If a field is not required, you simply need to test for its presence first.
C++: exec.isSetField(1)
or exec.isSetField(field)
(there might also be a exec.isSetAccount()
, not sure)
Java: exec.isSetField(1)
or exec.isSetAccount()
or exec.isSetField(field)
C#: exec.IsSet(1)
or exec.IsSetAccount()
or exec.IsSetField(field)