Skip to Content

NetWeaver BPM 7.20: Generating unique value with built-in mapping functions


Related to my NetWeaver BPM 7.20: Enhanced task notification, I asked the way to get timestamp as unique value in BPM. This blog shows how to get timestamp by using built-in mapping functions, hence you don’t need to write any java codes.


Sample Process

Here is an example process which has two data objects. “StartDateTime” is string, “TaskKey” is long type. Both objects intend to store timestamp.

Sample Process Diagram

Mapping is below.

Mapping of sample process


Current dateTime as string

NetWeaver BPM 7.20 has built-in mapping function “current-dateTime()”, it returns current timestamp in xsd:dateTime format. And it can be cast to xsd:string. String is easy to be used in mapping and task parameters.

Here is the mapping expression below.


At runtime, “StartDateTime” holds timestamp in xsd:dateTime format.

dateTime in xsd format

Current dateTime as UNIX time

Let’s make one more hack. You can get current timestamp in UNIX time as long integer. UNIX time means erapsed time since 1970-01-01. It can be millisecond scale on Java systems.

You can use “subtract-dateTimes-as-milliseconds()” build-in function, it returns difference of two dateTime objects in millisecond scale. You can get current UNIX time by subtracting zero from current time. As described above, UNIX zeto time is 1970-01-01.

subtract-dateTimes-as-milliseconds(current-dateTime(), dateTime("1970-01-01"))

You can see such result at runtime.

UNIX time in milliseconds scale


Strictly, timestamps are not unique value because multiple process instances can be started at same time. But timestamps will rarely conflict in millisecond scale, so it will not be serious problem in actual use.

You should consider timestamp confliction on implementing large or high volume systems.


1 Comment
You must be Logged on to comment or reply to a post.
  • Is UNIX zeto time is 1970-01-01  common for all unix servers? Please let me know.

    I have done teh same thing like the way you explained and able to get the task ket from start time- unixzero time. But when passed the same task key to wd code to get teh task Key from protocol adapter ,its giving me value as null and hence not able to proceed.Please helpme on this

    String taskKey = WDProtocolAdapter.getProtocolAdapter().