|
| 1 | +--- |
| 2 | +sidebar_position: 80 |
| 3 | +title: Mapping |
| 4 | +--- |
| 5 | + |
| 6 | +# Mapping |
| 7 | + |
| 8 | +## What is a Mapping? |
| 9 | + |
| 10 | +In **Simplicité**, a *Mapping* allows to copy or link data from one object (A) to another (B), **by value**, not by reference. This mechanism is used to populate fields, filter lists, or simulate relationships between business objects when a direct link does not exist or is not appropriate. |
| 11 | + |
| 12 | +It provides a way to: |
| 13 | +- Transfer field values between objects without persisting a relational reference. |
| 14 | +- Dynamically populate a list of values via a data service, without saving them to the database. |
| 15 | +- Create flexible and decoupled interactions between business objects. |
| 16 | + |
| 17 | +## When should a Mapping be used? |
| 18 | + |
| 19 | +Mappings are useful in several scenarios: |
| 20 | + |
| 21 | +- 💡 **No relational link makes sense**: The two objects are conceptually unrelated in database terms, but need to share some data. |
| 22 | +- 📝 **Copy by value**: You want to duplicate information rather than point to a source (e.g., copying customer info into an invoice). |
| 23 | +- 📄 **Dynamic data sources**: You want to show values from a service or calculation. |
| 24 | + |
| 25 | +## Mapping Types |
| 26 | + |
| 27 | +There are three kinds of mappings depending on the direction of the data flow: |
| 28 | + |
| 29 | +- **In Mapping** |
| 30 | + Filters the *mapped object* using the value from the *source attribute*. |
| 31 | + → *Used for filtering / selecting data based on a field of the current object.* |
| 32 | + |
| 33 | +- **Out Mapping** |
| 34 | + Assigns the *mapped attribute* using the value from the *source attribute*. |
| 35 | + → *Used for copying the value into the target.* |
| 36 | + |
| 37 | +- **In/Out Mapping** |
| 38 | + Combines both filtering and value transfer: |
| 39 | + → *Used when the incoming value is used for both selection and data population.* |
| 40 | + |
| 41 | +## How to configure a Mapping? |
| 42 | + |
| 43 | +1. Go to **Business objects > Mapping** or access the Mapping section in the objectfield configuration. |
| 44 | +2. Click **Create** to define a new mapping. |
| 45 | +3. Fill in the fields: |
| 46 | + - **Name** – logical name of the mapping. |
| 47 | + - **Object Linked object Code/ Source field** – The origin of the data. |
| 48 | + - **Mapping linked object Code / Mapped field** – The recipient of the value. |
| 49 | + - **Type** – In, Out, or In/Out. |
| 50 | + - **Module** – The Module to which it belongs. |
| 51 | +4. Save and test the behavior in your business object form. |
| 52 | + |
| 53 | +## Advanced configuration with Hooks |
| 54 | + |
| 55 | +To further customize the behavior of a mapping, the following hook can be overridden in your object script: |
| 56 | + |
| 57 | +```java |
| 58 | +public void initDataMapSelect(String map, String field, Object value) { |
| 59 | + // Custom logic to define dynamic filtering or mapping logic |
| 60 | +} |
0 commit comments