Expression toHex with zero padding

I have a fault code (in decimal) which I want to display in hex. I am using an expression tag with the expression '16#' + toHex([.]FaultCode), which works, but when the fault code is zero, it displays 16#0 instead of 16#0000.

I can’t use the numberFormat function because once I convert it to hex it becomes a string, and I can’t work out how to use stringFormat to achieve my aims.

Any way to achieve this without resorting to a script?

stringFormat("16#%04x", {[.]FaultCode})

1 Like

Excellent, thankyou!