Thursday, August 18, 2016

Padding preceding zeros to Colleague ID

In Colleague, ID numbers often have preceding 0s, and these are often truncated as the data is imported into Colleague. To add a small check to the ID to make sure it always is 7 number-long, you can add the following:

* Add zeros padding to PERSON ID
X.PERSON.ID.LEN = LEN(A.PERSON.ID)
X.ZEROS.TO.PAD = 7 - X.PERSON.ID.LEN
IF (X.ZEROS.TO.PAD GT 0) THEN
   A.PERSON.ID = STR("0", X.ZEROS.TO.PAD) : A.PERSON.ID
END

2 comments:

  1. You can also do the following (assume that X.ID contains "123456" and you want it to be "0123456")

    X.ID = ( "0000000" : X.ID )[7]

    which starts off by prefixing X.ID with 7 zeroes, then using only the last 7 characters

    ReplyDelete
  2. This is an interesting approach. I didn't know Envision supported that. Thanks for sharing.

    ReplyDelete