Monthly Archives: August 2024

Boomi: Check if already in cache before adding

I found myself with the error

Found more than 1 document in the document cache (index: dummyUserIndex, keys: [id (Root/Object/id) = 100])

and figured I just need to add a Decision Shape and check if the key (object) is already in the cache and then I would not add it. BUT it turned out to more complicated than I first thought.

Here is my first attempt…

Seems reasonable … I have 2 steps, first I check if the object is in the cache and if it is I don’t do anything, and if it is not I go and fetch and add it to the cache.

Problem is that the json that comes in is a list of objects

A deliberate duplicate to show the point I am making

Now what we end up having is 6 json objects, when Boomi processes that , it will process ALL of them through the Decision Shape (“Already in cache?”) above before it does anything else, and hence NONE of them are in the cache.

So when we execute it, it looks like this

Except for the error we get, we can see a peculiar thing, we never get a cache hit, instead we get all cache misses !!!

I ended up having to add a Flow Control shape

And select “Run each document individually”, see below

Now it runs fine …

We can see that we have a cache hit ! this is great, and we also did not get an error 🙂

Over and out !

Boomi: Dynamic Document Properies; in shapes and Groovy Scripts

In my case I wanted to count the number of elements inside an XML that was a result I got back from a SAP query. Below a small example.

Inside the Set Properties shape you specify a Dynamic Document Process like this

In the Groovy script we set that attribute according to the full path of the dynamic process property which must be prefixed with document.dynamic.userdefined

document.dynamic.userdefined.rowcount

e.g.

When you later on try to access the Dynamic Document Property you need to just use the last part again, in my example “rowcount”

Boomi: Create XML or JSON document through Message shape

Creating a JSON object in the message shape like this

Here it is important to that the message starts with ‘ and ends with a ‘ (single quote)

Creating XML document

In JSON you need that the message starts with ‘ and ends with a ‘ (single quote), BUT this is not necessary for XML, but works too.

However here you should NOT have the <?xml> tag in front cause then Boomi is unable to parse it as an XML element.

<?xml version=”1.0″ encoding=”UTF-8″ standalone=”no”?>

including the xml tag is not working !!!

And if you do forget this is the error you can expect

The test run for fetch Materials from MARA (SAP) you are attempting completed with the following errors: Embedded message: Unable to create XML files from data, the document may not be well-formed xml ; Caused by: Illegal processing instruction target (“xml”); xml (case insensitive) is reserved by the specs. at [row,col {unknown-source}]: [2,5]

Using Special characters in XML…

So if you intend to have a special character like a single quote or similar then you need to XML encode them. Use a tool like https://coderstoolbox.net/string/#!encoding=xml&action=encode&charset=us_ascii

E.g. if you would like to have an xml that looks like this

MAKTL EQ ‘ABC123’

SAP query example where single quotes are used

Then that should be converted into

MAKTL EQ &#39;ABC123&#39;

This is how the encoded XML should look like