// This module is included in the following assemblies:
// as_mapping-data.adoc

[id='combine-multiple-source-fields-into-one-target-field_{context}']
= Combining multiple source fields into one target field

In a data mapper step, you can combine multiple source fields into one 
compound target field. For example, you can map the `FirstName` and `LastName` 
fields to the `CustomerName` field.

.Prerequisite
For the target field, you must know what type of content is in each
part of this compound field, the order and index of each part of the content, 
and the separator between parts, such as a space or comma. See
link:{LinkSyndesisIntegrationGuide}#example-missing-unwanted-data_map[Example of missing or unwanted data]. 

.Procedure

. In the *Target* panel, click the field into which you want to map more 
than one source field and then click image:images/integrating-applications/create-mapping-icon.png[the Create new mapping icon]. The *Mapping Details* panel opens. 

. In the *Mapping Details* panel, from the *Source* drop-down list, select one or more data fields that you want to map to.
+
When you are done you should see a line from each of the source fields to
the target field. 
+
In the *Mapping Details* panel, above *Sources*, the data mapper 
displays the default multiplicity transformation, which is *Concatenate*.
This indicates that execution of the mapping applies the *Concatenate*
transformation to the values in the selected source fields and maps 
the concatenated value to the selected target field. 

. In the *Mapping Details* panel, configure the mapping as follows: 

.. Under *Sources*, in the *Delimiter* field, accept or select 
the character that the data mapper inserts in the target field between 
the content from different source fields. The default is a space.

.. Optionally, in each source field entry, you can click image:images/integrating-applications/transformation-icon.png[the Transformation icon] to apply a transformation to the source field value before it gets mapped to the target field. 

.. Under *Sources*, check the order of the entries for the source 
fields that you selected. The entries must be in the same order as 
the corresponding content in the compound target field.
+
If the entries are not in the correct order, change the index number for the field entries to achieve the same order. 
+
If you mapped a source field to each part of the compound target field, 
skip the next step.

.. For each source field entry that does not already have the same 
index as the corresponding data in the target field, edit the index 
to be the same. Each source field entry must have the same index 
as the corresponding data in the target field. The data mapper 
automatically adds padding fields as needed to indicate missing data.
+
If you accidentally create too many padding fields, click image:images/integrating-applications/TrashIcon.png[the Trash icon] for each extra padding field to delete it.

.. Optionally, under *Targets*, click image:images/integrating-applications/transformation-icon.png[the Transformation icon] to map 
the content into the target field and then apply a transformation as described in link:{LinkSyndesisIntegrationGuide}#transform-target-data_map[Transforming source or target data]. 

. Optionally, preview the data mapping result: 
.. Click image:images/integrating-applications/preview-mapping-icon.png[the Show/Hide Preview Mapping icon] to display a text input field on each source
field for the currently selected mapping and a read-only result field 
on the target field of the currently selected mapping. 
.. In the source data input fields, type sample values.
+
If you reorder the source fields or add a transformation to the mapping
then the result field on the target field reflects this. If the data mapper
detects any errors, it displays informative messages at the top of the 
*Mapping Details* panel. 

.. Hide the preview fields by clicking 
 image:images/integrating-applications/preview-mapping-icon.png[the Show/Hide Preview Mapping icon] again. 
+
If you redisplay the preview fields, any data
that you entered in them is still there and it 
remains there until you exit the data mapper. 

. To confirm that the mapping is correctly defined, click
image:images/tutorials/grid.png[the Mapping Table icon] to display (in table format) the mappings defined in this step. A mapping that combines the values of more than one source field
into one target field looks like this:
image:images/integrating-applications/CombineMapping.png[the Combine Fields Mapping icon]. 
+
You can also preview mapping results in this view. Click 
 image:images/integrating-applications/preview-mapping-icon.png[the Show/Hide Preview Mapping icon] and then type text as described in the previous step.
Preview fields appear for only the selected mapping. Click another
mapping in the table to view preview fields for it. 

.Additional resource
Example of adding padding fields: 
link:{LinkSyndesisIntegrationGuide}#separate-one-source-field-into-multiple-target-fields_map[Separating one source field into multiple target field]. 

Although that example is for a one-to-many mapping, the principles are the same.
