usernameGenerator transform use A-Z as "uniqueCounter"

I want to crate username using first 5 chars from lastname + first 2 chars from firstname. below transform will solve my problem but
Que 1: how can I use unique counter as A-Z instead of numeric incremental values?
Que 2: if lastname or firstname is less than desired 5 or 2 substring will it return whatever default identityAttribute value?

e.g.
firstname = adam
lastname = smith

then my username should = smith.adz

(If a user exists in IDN or Active-Directory, Add A-Z to the user-login generated until a unique name is found.)

{
    "attributes": {
      "cloudMaxSize": "100",
      "cloudMaxUniqueChecks": "26",
      "cloudRequired": "true"
    },
    "isRequired": false,
    "multi": false,
    "name": "NETID",
    "transform": {
      "type": "usernameGenerator",
      "attributes": {
        "sourceCheck": true,
        "patterns": [
          "$ln$fi${uniqueCounter}"
        ],
        "ln": {
            "type": "substring",
            "attributes": {
              "input": {
                "type": "identityAttribute",
                "attributes": {
                  "name": "lastname"
                }
              },
              "begin": 0,
              "end": 5
            }
          },
        "fi": {
          "type": "substring",
          "attributes": {
            "input": {
              "type": "identityAttribute",
              "attributes": {
                "name": "firstname"
              }
            },
            "begin": 0,
            "end": 2
          }
        }
      }
    },
    "type": ""
  }

The username-generator transform only provides numeric values for the $uniqueCounter attribute. If you want to use A-Z you will need to type out each iteration of the pattern in the patterns block. For example:

"patterns": [
    "$ln$fia",
    "$ln$fib",
    ...
]

Thanks @colin_mckibben

You cannot use username generator transform for any random attribute on source but only that attribute which is defined as “accountID” in schema (nativeIdentity). For rest of the attributes it would not work.

1 Like

Thanks @chirag_patel that’s very important thing I was unaware of. This will help.

Sorry, I suppose to use this API to create Account Profile transforms.

{
    "attributes": {
        "cloudMaxSize": "100",
        "cloudMaxUniqueChecks": "25",
        "cloudRequired": "true"
    },
    "isRequired": false,
    "multi": false,
    "name": "UserID",
    "type": "string",
    "transform": {
        "type": "usernameGenerator",
        "attributes": {
            "sourceCheck": true,
            "patterns": [
                "$ln$fiA",
                "$ln$fiB",
                ...
            ],
            "ln": {
                "type": "substring",
                "attributes": {
                    "input": {
                        "type": "identityAttribute",
                        "attributes": {
                            "name": "lastname"
                        }
                    },
                    "begin": 0,
                    "end": 5
                }
            },
            "fi": {
                "type": "substring",
                "attributes": {
                    "input": {
                        "type": "identityAttribute",
                        "attributes": {
                            "name": "firstname"
                        }
                    },
                    "begin": 0,
                    "end": 2
                }
            }
        }
    }
}

Since, this is custom transform the UI shown is correct here?