Understanding Integration Cloud and how to get the most out of your implementation

Conditional Mapping – ICS Definitive Tip #6

The question of conditional mapping comes up regularly on the ICS part of community.oracle.com which prompted us to write this blog. So if you want the output of an integration in element X to contain value from element A or B depending upon element C there are a number of answers, each having pros and cons. So let’s look at them before we offer an example of how we would solve the simpler more common problem.. Your choices are ….

  • Use the power of XSLT within the mapping,
  • Use the conditional option Within a Basic Map Data or an Orchestration pattern,
  • Use a custom piece of JavaScript
XLST Condition in the flow Custom Javascript
Single path through the integration Simpler to read and see visually Can be used either in the condition oer the mapping. Easier to apply than XSLT directly.
ICS doesnt make it the easiest to write this, but reading is fairly easy Easy to visually understand, but means more maintenance effort Easy to incorporate, but makes the development process multistep

We have talked about the condition/filtering in the book, and we will tackle the use of JavaScript in its own Definitive Guide, so let’s look at the XSL mapping option, and probably the route that will cover most cases. In many respects this is nothing to do with ICS, and is all about the use of XSLT so you may find it helpful to have an XSLT reference to hand. To this end the following maybe useful:

  • W3C – perhaps not the easiest to read, but definitely definitive,
  • XMLSchool far more readable but keeps things simple, and focuses on XSLT to create (X)HTML content

Mapping illustration

Let’s now look at an example,using the schemas from Chapter 6 of the book, we can create a basic map data integration as you can see in the next screenshot. You don’t need to have the book, to follow the rest of the article, but it will be useful (not to mention we’d like you to buy a copy of it as well ūüôā )

Basic Map Data Integration

The screenshot shows the mappings already completed, but we’ll talk about the details in a moment. But you’ll note that the connections we¬†have created are new ones called FlightLocationRaquest_DT6 and FlightLocationRequestTarget_DT6. This has been done so we can export all the elements into a project archive.

So with the connection placed into the integration, we can talk about the mappings. The return mapping is a simple 1-to-1 name based mapping. The request to requestTarget however we have introduced an example XSL with conditional mapping using the xsl:choose, and xsl:otherwise operations to define the conditions and the test to determine which branch to take uses the contains() function. As you can see in the next screenshot.

Illustration of the conditional mapping

Before we drill into the process of creating the expression, it is worth describing what this expression does. The expression tests to see if the source¬†ident field contains the string ‘BA’. If it is then the ident has the value faFlightID mapped to the target ident ¬†value. ¬†Otherwise the target ident is made to be the same as the source Ident value.

Creating the conditional mapping

Let’s look more closely at the process of creating this expression. From the map view click on the ident field on the right hand side so we can enter the Build Mappings view as shown above. The next step is a little fiddly as the mapping editor isn’t as sophisticated editor as most IDEs.

As the book will explain the left hand side will provide access to operators, functions and accessible data values. We need to build the expression up on the right hand side by dragging and dropping the correct values and operators over. You should see the route on the right hand side which will refer to ident.

We can build our expression either using the if operation or a choose operation. The difference being choose allows us to have multiple conditions (a select statement if you like). For our example we have opted for the choose. This is more of a personal preference – as it allows conditions to be added later (unless the result can only ever be binary).

test inb the conditional mapping

So from the left hand side locate the choose function and drop it over the ident field. The tree will then extend to show the choose part. To do this we now need to define the when test. So locate the test operator and drop it onto the choose. Then find the contains function and drop it on test.  Within the contains function will be two elements, we can hardwire the literal expression BA into one, in the other we need to locate the ident field in the source. As a child of the when part we also need to apply a select operator and then the faFlightId from the source. With the 1st condition applied the alternate path is needed. This requires the otherwise function to be added. Within the otherwise branch the select function is added and then the source element required

When adding elements it is important to have the correct element selected to be editable otherwise things won’t behave as expected. The indication of which element can be edited is indicated by the colour of the pencil, which is blue for the element able to accept values and grey when they can’t. You can switch the edit state by clicking on the pencil icon.

Once the expression is completed we can save the conditional expression and close the Build Mappings screen. Once completed the mapper will appear as shown in the next screenshot. You will note, that 2 fields are linked to the ident output.

Mapper view once conditional mapping is applied

Testing the expression

As the book explains, we can test the mapping without needing to deploy and execute the integration as the mapping tool as a test utility. ¬†This can be accessed from the Build Mapping screen. Once in the Test Mapper¬†screen we can the Generate Inputs with the button. Once generated we need to edit the value ident value as this is what gets used in the test. Let’s set the source ident to ‘BA‘ and then execute the mapping with the Execute button. Once executed look at the Ident in the Output. The output put value should match that faFlightID.

testing the conditional mapping

As you have now seen we can use the transformation to conditionally map values. This mapping is still relatively simple and a lot more could be done. Limitations are largely down to what can be done with XSL.


You can find the .iar file for this scenario here.


Differentiating the ICS Agent Types – Definitive Tip #5


Connecting directly to DBaaS – ICS Definitive Tip #7

1 Comment

  1. Ankur


    How can we check if a variable doesn’t contain blank value or null.

    For example: if we have one variable called data, then We want to check if(data!=””) or if(data!=null)


Leave a Reply

Your email address will not be published. Required fields are marked *

Powered by WordPress & Theme by Anders Norén