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.;
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.
- 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.
- Is there a property from the CAF side that would prevent sending empty strings in the document?
- Should I just stop whining and change all of the tests?
Any input would be appreciated.