Auto ID Methods


The LogicApp provides a convenient mechanism for scripts to access an, auto-incrementing identifier, e.g. for the purpose of generating unique session or call identifiers.

Before use, the Auto ID must be configured within the Logic Application’s <application> block, e.g.

    <application name="Test-Logic" module="LogicApp">
              <auto_id key="call_id" length="10" charset="alphanum"/>

Refer to the LogicApp configuration.

These methods are accessed via the “n2.n2svcd” module:

    local n2svcd = require "n2.n2svcd"

.auto_id [Synchronous]

The auto_id method requests a new value from the automatic ID generator.

These method argument list is:

Parameter Type Description
key String The key configured for the ID.


    local call_id = n2svcd.auto_id ('call_id')

The auto_id method returns the string value of the automatically incremented ID.

NOTE: The automatic incremented ID is based on a 63-bit cyclic integer.

In the case where multiple instances of the LogicApp are being executed (e.g. with the <application repeat= attribute) it is unlikely but theoretically possible that the same automatic ID may be generated for both instances.

To ensure absolute uniqueness when running multiple LogicApp instances, you may wish to consider incorporating a prefix to the ID such as the APPLICATION_PID or APPLICATION_IDX global Lua variables which are guaranteed to be unique between applications.