Hi,
The flow steps run synchronously, but do not wait for the server connect call to complete.
So after your first step, second step run immediately, irrespective of weather you have received a response from the first call.
What you need to do is put the JS calling Flow in the dynamic success event of the server connect. Then it should work reliably for you.
As for setting the 'BADGE' value, it should be pretty straight-forward with dmx-html
or dmx-bind:value
. No need for flows or JS.
If you can share your HTML, I might be able to help better.