Math and counting with operation property



Counting with operation property:


Micro Focus Identity Manager is a big product with many different parts. Even with several years focusing on the product you find yourself learning new stuff on parts that you never stumbled over before.

A few years ago, Geoffrey Carman (aka geoffc) wrote an article about XPath and math

It is still very valid.

Recently I have found myself using the token "Operation property" more and more since it comes back in the publisher channel after I have done some things in the subscriber channel.

Operation property is great to work with if you need to act on the event after the event has been written to the application.

In that sense it works like a variable.

On this occasion I needed to add an operation property that included a number. Basically I would use it as a simple counter.

In the Input Transformation Policy set, I created a policy with a rule that then would increment the number with 1.

Simple enough.

This is the rule I created:

<do-set-op-property name="propertyNr">
<token-xpath expression="$propertyNr 1"/>

Where propertyNr is the operation property.

To my surprise it did not work! I thought I had gotten it all wrong and read many articles on XPath and counting, math, etc.

That was what led me to Geoffc's old article again, and then on other dwindling websites.

It turned out that operation property cannot be used in counting! At least I could not make it work. Not sure if this is anything that has been tested or intended. As often we tend to use the tokens in many ways, that was never the original intention.

I had to set a local variable first, so this is what the working code ended up looking like:

<do-set-local-variable name="lv_propertyNr" scope="policy">
<token-op-property name="propertyNr"/>
<do-set-op-property name="propertyNr">
<token-xpath expression="$lv_propertyNr 1"/>


Hope this can help someone to avoid some wasted hours.



How To-Best Practice
Comment List
  • You are probably right about this. I was just amazed that op-properties was not automatically exposed as variables. Not because they are supposed to but because of how I treat them.
  • In short, you are saying that an Operation Property is not available as a variable in XPATH? I think that is correct. You would, as you note, have to set a variable with its value first.

    You could probably try the XPATH of:
    operation-property/@propertyNr + 1

    Or maybe ../operation-property/@propertyNR + 1
  • You can do this with pure x-path. No need for the local variable.

    The issue with your initial approach is that you assume that op-properties are automatically exposed as variables by the engine. As you note, this is not the case.

    an x-path expression of ./operation-data/@propertyNr + 1 should do what you want...
Related Discussions