That function does have the following comment for OM V8 and
I'm guessing that is what you are encountering.If the object has been activated more than once, the oldest RunID is returned.
I'm assuming that the script logic that is using the GET_UC_OBJECT_NR() function is not in the actual object that has failed and is restarted but by some other object.
When we have to deal with this issue we will sometimes have the object update a Variable that contains the needed RunID(s). That way other objects can have access to the task's run and restart RunIDs. Something like the following is normally placed in the Pre Process.
:SET &me_runid = SYS_ACT_ME_NR()
:PRINT "RunID is &me_runid"
:IF SYS_ACT_RESTART() = "Y"
: SET &me_re_runid = SYS_ACT_RESTART_ME_NR()
: PRINT " and the restart RunID is &me_re_runid"
: ENDIF
! Store RunID in a Variable object as needed.
We normally use Deactivate Always but this also works for all deactivation values. This works reliably for us whether the object is executed as a single task in a flow or concurrently (parallel).