Build in now() function transformation returns empty string

Hello
In our system at some point we need to transform current date to some specific format with FEEL expression and the formula is

substring before(string(now()), “.”) + “Z”

But from time to time, non-deterministically instead of value i.e.: “2025-12-01T12:34:56Z” we receive only “Z” letter.
This happens very rare and it is hard to reproduce. We are using Camunda 8.6.29. What can be the issue? Is this something related to Camunda engine or problem is something else?
As a temporary workaround we added check, if formula returns only “Z” and retry with calling it.
Kind regards

Hi @DomiP, welcome to the forums! FEEL will resolve expressions to NULL if some operations fail, such as type conversions. I suspect that’s the high level cause - sometimes, some part of substring before(string(now()), “.”) doesn’t resolve and returns NULL, leaving you with just “Z” as the final result. The question is why.

Can you share a bit more about where you’re using this expression? Is it in a script task, or in a result variable or output mapping, or in a form?

Hello @nathan.loding , I’m using this in script task as part of json creation. I cannot share full json, but is is more like:

{
”field1”: “value1”,
”timeAndDate” : substring before(string(now()), “.”) ,
”field2”: “value2”
}

Thanks @DomiP - this is definitely an odd issue. I am going to share this with some of our engineers and see if they have any thoughts!