Sidebar

How to test if a node or field in a message is blank?

0 votes
1.4K views
asked Jul 28, 2015 by rich-c-2789 (16,180 points)

1 Answer

+1 vote

Versions prior to 2.0.42 would use something like:

if (source.checkNodeExists('PID-6')) {
   var pid6 = source.getNode('PID-6');
   if (StringUtils.isBlank(pid6)) {
      qie.debug("Do Something useful when blank");
   } else {
      qie.debug("Do Something useful when NOT blank");
   }
} else {
   qie.debug("Do something useful when not exists");
}
As of version 2.0.42 a couple new methods (checkNodeIsBlank and checkNodeIsNotBlank) were added to the code wizard that would simplify the above code.  The above code is still valid
if (source.checkNodeIsBlank('PID-6')) {
   qie.debug("Do Something useful when blank");
} else {
   qie.debug("Do Something useful when NOT blank");
}
See the Code Wizard under Source and Message menus for these methods and further documentation.  
 
Whitespace, as refered to in the Code Wizard, refers to non printable characters.  Some non printable characters are not allowed based on the message type used.  For example some message types allow white space like a "Vertical Tab" (veritcal tab \u000B differs from a horizontal tab \u0009) that is no longer very useful in modern computing.  XML does not allow vertical tabs.  Other non printable characters (whitespace) may not be encodable given the character encoding used.  for Example ISO8859 does not allow "Line Separator" (\u2028) or "Paragraph Separator" (\u2029) while UTF8 does.  The default character encoding for the TextMessageModel is ISO8859.
 
answered Jul 28, 2015 by rich-c-2789 (16,180 points)
...