Skip to Content
Author's profile photo Meghna Shishodiya

Custom function with multiple output in Message Mapping


Quite often there are cases in Message Mapping, where one condition defines values for multiple target fields.

The developer is required to write one custom function per target field for checking the very same condition and assigning the required values. This design made it difficult to maintain the mapping.

Cloud Integration now enables a new feature that allows a custom function module to compute and return the values of multiple target fields together – a custom groovy function that is added to a message mapping is used for this purpose.


The custom groovy function allows you to assign values to as many output parameters as needed. You can check the condition in the function only once and assign values to multiple output parameters. These output parameters can then be assigned to the corresponding target fields via the graphical representation in the defined order.

The computation happens only once in the custom function module.

Step wise procedure of how to add a custom groovy function to message mapping can be found here.

The function signature is as follows:
def void <Function Name>(<data type 1>[] <Input Param1>,…,
<data type N>[] <Input
Param N>, Output <Output
Parameter 1>,…,
Output <Output Parameter N>)

The place holder for the return type of the function is set by default to void.

The actual return parameters are defined inside the brackets after the input

The input parameter can only be an Array of type Float, String, Boolean and Int. Based on how the source context is set, the input can be collection of nodes instead of one node. In order to be able to handle all cases, we expect input parameters as arrays. Refer to the sample function below for an example.

The return parameter is only of type Output. Output is a list object so it can be assigned multiple values if the scenario demands. The multiple values of the output parameters will be assigned as multiple occurrence of the target field.

You can add as many number of input and output parameters to this function module.

In the example below, we are calculating the various components of the salary of an employee based on his location. Finally, after all the calculations, the function shall return all the 3 components of the salary together:

Available in Eclipse tooling since July 2017
Web Tooling: since October 2017



Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Can you please share the entire code, so we can see how the three outputs are returned. I am trying to have a single input and two output custom function, but not able to do that.

      Thank you

      Author's profile photo Meghna Shishodiya
      Meghna Shishodiya
      Blog Post Author

      Hello  Siddartha, can you please share the error you are facing. The remaining code is just doing additional assignments for other locations. Typically, you would need to assign the output to the target field through the graphical editor, not through this module. If this still does not solve the problem, we can have a quick meeting to check. Thanks!


      Author's profile photo Athar Iqbal
      Athar Iqbal

      Hi Meghna, I need to do something similar in my MM but it seems more complex. I need to pass an XML node to the custom function and interrogate certain values and count the entries in node that pass the criteria and return the count back from function. Any thoughts on how to do that, especially how to pass XML node to function? I am assuming as Context but I would love some suggestion.

      Thanks in advance


      Author's profile photo Sudha Kantamneni
      Sudha Kantamneni

      Hi Meghna, Thank you for the details. I have a question about debugging this custom function.. Is there any way to get the trace of variables using any trace/ log functions?




      Author's profile photo Former Member
      Former Member


      The link for "how to add a custom groovy function" is dead. Please could someone update this?