Skip to main content
July 8, 2025
Question

Getting the same value from a expression rule

  • July 8, 2025
  • 7 replies
  • 0 views

Hi all,

I have a process model that calls an expression rule to generate a 6-character random alphanumeric string. I encountered a case where two instances of the process model were triggered at the same time (based on time logs), and both received the same generated value from the expression rule.

I understand that there's always a chance for it to generate the same value. However, I’d like to ask:

Is it possible that both process models used the same instance or execution thread of the expression rule, which might explain why the same value was returned?

    7 replies

    shubhama926776
    July 8, 2025

    No, Expression rules don't share execution threads. Each process instance gets its own separate execution.
    Your random generator likely uses system time as a seed. When two processes run at the exact same millisecond, they get the same seed  -> same random value.

    July 8, 2025

    Thank you for answering. Is there a way to check this?

    shubhama926776
    July 8, 2025

    Try this code once.

    mid(
      substitute(
        substitute(
          text(now(), "yyyyMMddHHmmssSSS"), 
          ":", ""
        ),
        " ", ""
      ),
      12,
      6
    )


    I would recommend you to use pp!id with now() to make it more unique combination.

    stefanhelzle0001
    July 8, 2025

    6 characters isn't that much randomness. So, yes, this can happen.

    What do you do with this value?

    July 8, 2025

    We’re using it as an identifier. Unfortunately, we can't add more characters due to an external system limitation.

    stefanhelzle0001
    July 8, 2025

    OK, but then you can't just use a random value. You will get duplicates over time.

    Did you consider to just use the primary key of a record as the identifier? This would guarantee uniqueness. And you can convert that number into an alphanumeric string if needed.

    harshas2775
    July 8, 2025

    Any process instance’s id is unique always! If you want random yet unique string then consider using the process id -pp!id- along with whatever code you have for the random string!