Help with Regex Transform - Prepend '000' to Last 5 Digits of Employee ID

Hi

I’m trying to create a transform that takes the last 5 digits of a 6 digit Workday Employee ID (FILENUMBER) and then prepends 000. For example, if the FILENUMBER is 123456, I expect the output to be 00023456.

The regex I use: ^.*(\d{5})$ with substitute 000$1 which I tested on regex101 and gets the expected result

With this I created the following transform

{
    "name": "employeeId 2 employeeNumber",
    "type": "replace",
    "attributes": {
        "regex": "^.*(\\d{5})$",
        "replacement": "000$1"
    },
    "internal": false
}

but in the identity mapping data preview I always get this error.
I also tried with a few other regex variations, but result is always the same.

What am I doing wrong?

Thanks for any insights!

Hi,

Use Left Pad Transform below to achieve:

{
  "attributes": {
    "padding": "0",
    "length": "6",
    "input": {
      "attributes": {
        "sourceName": "HR Source",
        "attributeName": "employeeID"
      },
      "type": "accountAttribute"
    }
  },
  "type": "leftPad",
  "name": "Left Pad Transform"
}
1 Like

In addition to the left pad transform that @gogubapu shared, you can use the substring transform to make sure you only get the last 5 of the 6 digits in the employee ID.

1 Like

In the end I went with the ‘getEndOfString’ operation in combination with the ‘Concatenation’ operation as it was mentioned in the ‘Substring’ operation documentation that the substring transform does not provide an easy way to get the last n characters of a string.

Still curious to know why the regex throws the rendering template error so if someone is able to shine a light on that

{
    "name": "Format Employee ID with Prefix",
    "type": "concat",
    "attributes": {
        "values": [
            "000",
            {
                "attributes": {
                    "name": "Cloud Services Deployment Utility",
                    "operation": "getEndOfString",
                    "numChars": "5"
                },
                "type": "rule",
                "name": "Get End Of String Transform"
            }
        ]
    }
}