# usernameGenerator transform use A-Z as "uniqueCounter"

**URL:** <https://developer.sailpoint.com/discuss/t/usernamegenerator-transform-use-a-z-as-uniquecounter/1463>\
**Category:** SHF Discussion and Questions\
**Created:** [August 31, 2021, 12:53pm UTC](https://developer.sailpoint.com/discuss/t/usernamegenerator-transform-use-a-z-as-uniquecounter/1463 "2021-08-31T12:53:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Swapnil\_Kotwal](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@Swapnil\_Kotwal](https://developer.sailpoint.com/discuss/u/Swapnil_Kotwal)\
**Post date:** [August 31, 2021, 12:53pm UTC](https://developer.sailpoint.com/discuss/t/usernamegenerator-transform-use-a-z-as-uniquecounter/1463/1 "2021-08-31T12:53:18Z")

</div>

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.)

```auto
{
    "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": ""
  }

```

---

<div class="post-metadata">

**Author:** ![colin\_mckibben](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/colin_mckibben/32/37182_2.png) [@colin\_mckibben](https://developer.sailpoint.com/discuss/u/colin_mckibben)\
**Post date:** [August 31, 2021, 3:31pm UTC](https://developer.sailpoint.com/discuss/t/usernamegenerator-transform-use-a-z-as-uniquecounter/1463/2 "2021-08-31T15:31:04Z")

</div>

The [username-generator transform](https://community.sailpoint.com/t5/IdentityNow-Wiki/IdentityNow-Transforms-Username-Generator/ta-p/180577) 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:

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

```

---

<div class="post-metadata">

**Author:** ![Swapnil\_Kotwal](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@Swapnil\_Kotwal](https://developer.sailpoint.com/discuss/u/Swapnil_Kotwal)\
**Post date:** [September 1, 2021, 4:47am UTC](https://developer.sailpoint.com/discuss/t/usernamegenerator-transform-use-a-z-as-uniquecounter/1463/3 "2021-09-01T04:47:34Z")

</div>

Thanks @colin_mckibben

---

<div class="post-metadata">

**Author:** ![cpatel](https://avatars.discourse-cdn.com/v4/letter/c/48db29/32.png) [@cpatel](https://developer.sailpoint.com/discuss/u/cpatel)\
**Post date:** [September 1, 2021, 4:54am UTC](https://developer.sailpoint.com/discuss/t/usernamegenerator-transform-use-a-z-as-uniquecounter/1463/4 "2021-09-01T04:54:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Swapnil\_Kotwal](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@Swapnil\_Kotwal](https://developer.sailpoint.com/discuss/u/Swapnil_Kotwal)\
**Post date:** [September 1, 2021, 4:59am UTC](https://developer.sailpoint.com/discuss/t/usernamegenerator-transform-use-a-z-as-uniquecounter/1463/5 "2021-09-01T04:59:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Swapnil\_Kotwal](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@Swapnil\_Kotwal](https://developer.sailpoint.com/discuss/u/Swapnil_Kotwal)\
**Post date:** [September 2, 2021, 12:16pm UTC](https://developer.sailpoint.com/discuss/t/usernamegenerator-transform-use-a-z-as-uniquecounter/1463/6 "2021-09-02T12:16:49Z")

</div>

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

- List: [list-provisioning-policies | SailPoint Developer Community](https://developer.sailpoint.com/idn/api/beta/list-provisioning-policies)

- Get: [get-provisioning-policy | SailPoint Developer Community](https://developer.sailpoint.com/idn/api/beta/get-provisioning-policy)

- Update (via PUT): [replace-provisioning-policy | SailPoint Developer Community](https://developer.sailpoint.com/idn/api/beta/replace-provisioning-policy)

---

<div class="post-metadata">

**Author:** ![Swapnil\_Kotwal](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@Swapnil\_Kotwal](https://developer.sailpoint.com/discuss/u/Swapnil_Kotwal)\
**Post date:** [September 3, 2021, 12:08pm UTC](https://developer.sailpoint.com/discuss/t/usernamegenerator-transform-use-a-z-as-uniquecounter/1463/7 "2021-09-03T12:08:21Z")

</div>

```auto
{
    "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?

 ![userID](https://global.discourse-cdn.com/sailpoint/original/1X/51522d881cc726bf9357a7fa59da54127937c2ce.png)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sailpoint/original/2X/f/f2136700ed5e3703e0b85e02f6be799dacca7735.png) [@system](https://developer.sailpoint.com/discuss/u/system)\
**Post date:** [July 19, 2023, 2:22pm UTC](https://developer.sailpoint.com/discuss/t/usernamegenerator-transform-use-a-z-as-uniquecounter/1463/9 "2023-07-19T14:22:02Z")

</div>


