How Do I 'Blank' Out a Field in an Application Request?

Document created by gbockelmann Employee on Nov 10, 2011
Version 1Show Document
  • View in full screen mode
Three common approaches for how to update a field with a blank value when sending an XML request to an application.
Three common approaches often found in modern web service APIs are:
  1.           Simply omit the element from the request. This means you must always supply values for all fields otherwise the values are blanked out.
  2.           Include an empty XML element in the request (e.g. <MyFieldName/>).
  3.           Populate special "field to null" element with the name of the field (e.g. <fieldToNull>My Field Name</fieldToNull>).
For #1, there is actually nothing special you need to do to achieve this: simply map the desired fields from the source to destination and only the fields that contain a non-blank value will be output. However for the other approaches, some special profile and mapping configuration is required.

For #2, to force the mapping engine to output an empty element when there is no source value being mapped to that field, edit the destination XML profile, select the desired Data Element, and set Min Occurs=1. Then on the Options tab, enable Respect Min Occurs. Then in the map, just map the fields normally. If the source document contains a value for the field, that element will be output; if it does not contain a value, an empty element will still be output.

#3 is a little trickier because it involves populating a separate field with the name (not the value) of the field to null but only if the source does not contain a non-blank value. To accomplish this, you will need to modify the destination profile and use a number of map functions to conditionally check each source field that may need to be blanked out. First, edit the destination profile and manually replicate the fieldToNull (or similarly named) element as many times as the number of potential fields you may need to blank out. Then in the map, create a user defined map function with a simple if/else script to inspect the source value and either output the source value to the "normal" destination field or the field name (manually supplied as a function input) to the fieldToNull field. Add the map function for each field you need to inspect, specifying the field name and mapping to a particular fieldToNull instance. See screen shots below.


These are a few common approaches that applications use but of course your specific application may differ. Always be sure to review your application's API documentation to understand how it works and identify any special considerations.
1 person found this helpful