Need the same JS function in multiple responses?

Define it in the script library and use it in any JS-capable input field:

// office-id is [0-9]{10}
function formatOfficeId(oi) {
  while( oi.length < 10 ) {
    oi = "0"+oi;
  }
  return oi;
}
and then in the response:
...
  "office-id": formatOfficeId(input.oid),
...