Math and counting with operation property

1 Likes
over 3 years ago

 

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 https://www.netiq.com/communities/cool-solutions/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">
<arg-string>
<token-xpath expression="$propertyNr 1"/>
</arg-string>
</do-set-op-property>



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">
<arg-string>
<token-op-property name="propertyNr"/>
</arg-string>
</do-set-local-variable>
<do-set-op-property name="propertyNr">
<arg-string>
<token-xpath expression="$lv_propertyNr 1"/>
</arg-string>
</do-set-op-property>



Amazing.

Hope this can help someone to avoid some wasted hours.

 

Labels:

How To-Best Practice
Comment List
Anonymous
Parents Comment Children
No Data
Related Discussions
Recommended