Share this link

    Home / Tradeshift Documentation / Tradeshift Partner Apps / Babelway / Chapter 4. Channels

    Metadata usage

    1689 0 Created on 2021-01-26 12:02:58; Last updated on 2022-07-01 13:01:37

    This page shows you some examples of locations in the application where metadata can be used.

    Changing value assigned to a system metadata in drag and drop transformation

    See details in Using or changing metadata.

    Using metadata to customize messages and file names

    You can use system or user defined metadata in your output gateways and email notification configuration. The metadata values can be used to name output files sent through output gateways or as part of a notification email subject and or body. The metadata used may even be different for success or failure messages as shown in the figures below.

    System metatada are referenced using syntax {com_babelway_messaging_context_***}. A list of available system metadata with returned variables and examples is available in the System Metadata appendix.

    mceclip0.png

    System metadata used to customize notification emails

     

    mceclip1.png

    System metadata used to customize file names

     

    User defined metadata are referenced using syntax {your_metadata} where your_metadata is the name of the user defined metadata you want to reference to as illustrated in the following example, where the earlier user defined metadata is used as a name for the file sent as email attachment.

    mceclip2.png

    User defined metadata used to customize attachment name

     

    Concatenate values from a loop in a metadata

    If you want to concatenate multiples values from a loop in a single metadata such as a message reference or a user defined metadata, you have 2 options:

    1. Use a full custom xpath:

    • Do not map any loop.

    • Create an Xpath custom expression such as:

    string-join (YOUR_XPATH, 'YOUR_SEPARATOR')

    Where YOUR_XPATH is the path to all the elements you want to concat such as:

    /ediroot/interchange/group/transaction/loop/segment[@Id='NAD' and element[@Id='NAD01'] = 
    'BY']/element[@Id='NAD02']/subelement[@Sequence='1']

    or

    /csv/line/field1

    Or drag a repeated element (such as the above mentioned line) on the custom function. All field1 elements under the repeated element will be concatenated and separated by the given separator.

    $arg1/field1

    YOUR_SEPARATOR is the separator between two elements of the list such as ' - ' for example.

    2. Use the functions get-metadata and set-metadata

    • Map the loops to the output metadata

    • Create an Xpath custom expression with the following expression:

      metadata-util:put($MSG,'com_babelway_messaging_context_message_reference', bfn:concat
      ('YOUR_PREFIX', 'YOUR_SEPARATOR', 'YOUR_SUFFIX', metadata-util:get($MSG,
      'com_babelway_messaging_context_message_reference'), $arg1))

      Where

      • YOUR_PREFIX is the prefix added at the beginning of the result, e.g.: ' here is the list of value: '

      • YOUR_SEPARATOR is the separator added between the different elements, e.g.: '    '

      • YOUR_SUFFIX is the suffix added at the end of the result e.g.: [i ' '[/i]

    • Drop the value of the element to the expression (= $arg1 )

    • Map the expression to the metadata

    

    0 people found this helpful.

    Related Articles