Empty strings in Document Fields

I have come across an annoying little issue and was wondering if anyone had handled this yet.

I have a service that receives a Document Type that contains about 15 fields that are to be used for Search Criteria. Based on the data elements in the Document I build a Dynamic SQL Statement to pull the data from the database. The search will work if any one or more of the criteria are filled out.

Everything worked just peachy until a CAF screen started using the service. When the CAF calls the service it sends the document containing empty strings (instead of nulls) in the fields if there is no data in the field.

Since I have 15 different fields to interrogate while building the Dynamic SQL statement, I am looking for a way to avoid independently checking each field for a NULL and an Empty string before proceeding.

To illustrate the current process, for each field we do the following:

on the field
<MAP $null> then do nothing
<MAP $default> add the criteria to the SQL Statement

The simple solution would be to modify the map step to handle an empty string, i.e.;

<service trim(fieldvalue)
<service length(fieldvalue)
on the length of the fieldvalue – evaluate labels
<MAP len(trim(fieldvalue)) > 0> add the criteria to the SQL Statement
<MAP $default> do nothing

I have noticed that when I run this service from Developer and do not check the box for “Include empty values for string types” the empty fields do not get passed to the service and everything ir OK. Once I check that box then all of the unused fields are passed with empty string values.

I want to enforce the data control in this service side since this service could be called from multiple CAF screens/other services.


  1. Does anyone out there know of a way to move an entire document into another document (of the same type) and remove the empty string values from the individual fields in one simple step? I was looking at the built in services and transformers but I don’t see anything that does this.
  2. Is there a property from the CAF side that would prevent sending empty strings in the document?
  3. Should I just stop whining and change all of the tests?

Any input would be appreciated.

I am not sure of there is a way to take care of all the empty fields in one step unless you write a java code. Why don’t you use regular expressions (%variable% == /[^\s]/) which should take take for null,empty,white spaces and tabs. You are already doing the Branch, just evaluate labels and use the above expression.

Thanks Talha! I’m pretty new at this and I forgot that we can use regular expressions. Seems like a good resolution.

Changing complete code or branch condition everywhere is not a good idea.

You might create a simple utility service with one string variable as input and one string variable as output. In this utility service, if input string is null or empty, don’t map anything to the output variable otherwise map input variable to output variable. Whenever you have input variable coming as null or empty, you will not get anything in output which is eventually null. This utility service can be used as transformer for all the fields from your input document to another temp document and then from temp document to the document used in branch.

Using this approach, you wont need to change your existing code much. You can change this utility service for such issues in future too like trimming input fields.