# Username Generator

**URL:** <https://developer.sailpoint.com/discuss/t/username-generator/69088>\
**Category:** SHF Discussion and Questions\
**Tags:** transforms, identity-security-cloud\
**Created:** [June 26, 2024, 2:40pm UTC](https://developer.sailpoint.com/discuss/t/username-generator/69088 "2024-06-26T14:40:00Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![vasanthrajsp29](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/vasanthrajsp29/32/20713_2.png) [@vasanthrajsp29](https://developer.sailpoint.com/discuss/u/vasanthrajsp29)\
**Post date:** [June 26, 2024, 2:40pm UTC](https://developer.sailpoint.com/discuss/t/username-generator/69088/1 "2024-06-26T14:40:00Z")

</div>

Hi All,

We have a requirement to create email for new users and write back to workday system, email pattern should (first latter of firstname + lastname + domain) I am able achieve this by below transform but problem is with {uniqueCounter} in username generator its starting with 1 even though the value is unique.

{  
“name”: “EMAIL\_ADDRESS\_WORK”,  
“transform”: {  
“type”: “usernameGenerator”,  
“attributes”: {  
“sourceCheck”: true,  
“patterns”: [  
“$fi$ln${uniqueCounter}@domain.com”  
],  
“fi”: {  
“type”: “lower”,  
“attributes”: {  
“input”:{  
“type”: “substring”,  
“attributes”: {  
“input”: {  
“type”: “identityAttribute”,  
“attributes”: {  
“name”: “firstname”  
}  
},  
“begin”: 0,  
“end”: 1  
}  
}  
}  
},  
“ln”: {  
“type”: “lower”,  
“attributes”: {  
“input”: {

```
                                "type": "identityAttribute",
                                "attributes": {
                                    "name": "lastname"
                                }
                            }
                        
                    }
                }
            }
        },
        "attributes": {
            "cloudMaxSize": "100",
            "cloudMaxUniqueChecks": "25",
            "cloudRequired": "true"
        },
        "isRequired": false,
        "type": "string",
        "isMultiValued": false
    }

```

for this I’m getting [jdeo1@domain.com](mailto:jdeo1@domain.com), Looking for valuable suggestion.  
Thanks!

---

<div class="post-metadata">

**Author:** ![KRM7](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/krm7/32/2685_2.png) [@KRM7](https://developer.sailpoint.com/discuss/u/KRM7)\
**Post date:** [June 26, 2024, 3:14pm UTC](https://developer.sailpoint.com/discuss/t/username-generator/69088/2 "2024-06-26T15:14:45Z")

</div>

Hi @vasanthrajsp29

Welcome to SailPoint Developer Community.

That wouldn’t be the case, are you sure that this email doesn’t exists, even under uncorrelated accounts ?

I hope you applied the transform at AD source.

Thanks  
Krish

---

<div class="post-metadata">

**Author:** ![bcariaga](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/bcariaga/32/1890_2.png) [@bcariaga](https://developer.sailpoint.com/discuss/u/bcariaga)\
**Post date:** [June 26, 2024, 3:22pm UTC](https://developer.sailpoint.com/discuss/t/username-generator/69088/3 "2024-06-26T15:22:37Z")

</div>

Hi @vasanthrajsp29.

Welcome to the SailPoint Developer Community 🙂

With the username generator transform, you can define multiple patterns. If you don’t want the counter used initially, you should define your first pattern without the use of that variable. In the next pattern, you can add the unique counter. The generator will try the first pattern for uniqueness before moving on to the next.

This should work for you:

```auto
{
    "name": "EMAIL_ADDRESS_WORK",
    "transform": {
        "type": "usernameGenerator",
        "attributes": {
            "sourceCheck": true,
            "patterns": [
                "$fi$ln@domain.com",
                "$fi$ln${uniqueCounter}@domain.com"
            ],
            "fi": {
                "type": "lower",
                "attributes": {
                    "input": {
                        "type": "substring",
                        "attributes": {
                            "input": {
                                "type": "identityAttribute",
                                "attributes": {
                                    "name": "firstname"
                                }
                            },
                            "begin": 0,
                            "end": 1
                        }
                    }
                }
            },
            "ln": {
                "type": "lower",
                "attributes": {
                    "input": {
                        "type": "identityAttribute",
                        "attributes": {
                            "name": "lastname"
                        }
                    }
                }
            }
        }
    },
    "attributes": {
        "cloudMaxSize": "100",
        "cloudMaxUniqueChecks": "25",
        "cloudRequired": "true"
    },
    "isRequired": false,
    "type": "string",
    "isMultiValued": false
}

```

You can learn more information on the Username Generator transform [here](https://developer.sailpoint.com/docs/extensibility/transforms/operations/username-generator).

If this or another post solves your issue, please be sure to mark them as a solution so others reviewing this thread can easily find the guidance they need.

Edit: The unique counter will be not be included in first run, so the additional pattern is not necessary.

---

<div class="post-metadata">

**Author:** ![vasanthrajsp29](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/vasanthrajsp29/32/20713_2.png) [@vasanthrajsp29](https://developer.sailpoint.com/discuss/u/vasanthrajsp29)\
**Post date:** [June 26, 2024, 3:53pm UTC](https://developer.sailpoint.com/discuss/t/username-generator/69088/4 "2024-06-26T15:53:11Z")

</div>

Hi @KRM7,

Yes, you’re right it’s not working for all scenario’s what would be the right suggestion here?

Writing cloud rule to achieve this would help?

Thanks!  
Vasanth

---

<div class="post-metadata">

**Author:** ![KRM7](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/krm7/32/2685_2.png) [@KRM7](https://developer.sailpoint.com/discuss/u/KRM7)\
**Post date:** [June 26, 2024, 4:03pm UTC](https://developer.sailpoint.com/discuss/t/username-generator/69088/5 "2024-06-26T16:03:52Z")

</div>

no need of a separate Transform even, just use Generator in Create Account Provisioning form.

Generator type is: Create Unique LDAP Attribute and use below pattern like this

`$(firstname).$(lastname)$(uniqueCounter)`

It did work for us.

Thanks  
Krish

---

<div class="post-metadata">

**Author:** ![bcariaga](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/bcariaga/32/1890_2.png) [@bcariaga](https://developer.sailpoint.com/discuss/u/bcariaga)\
**Post date:** [June 26, 2024, 4:15pm UTC](https://developer.sailpoint.com/discuss/t/username-generator/69088/6 "2024-06-26T16:15:27Z")

</div>

@MVKR7T Based on the attribute name, this doesn’t seem to be AD. Will Create Unique LDAP Attribute work?

@vasanthrajsp29 what is the target application?

---

<div class="post-metadata">

**Author:** ![vasanthrajsp29](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/vasanthrajsp29/32/20713_2.png) [@vasanthrajsp29](https://developer.sailpoint.com/discuss/u/vasanthrajsp29)\
**Post date:** [June 26, 2024, 4:25pm UTC](https://developer.sailpoint.com/discuss/t/username-generator/69088/7 "2024-06-26T16:25:05Z")

</div>

Hi Krish,

Create Unique LDAP Attribute can we use this to build business logic email pattern should (first latter of firstname + lastname + domain) will it be possible?

Thanks!  
Vasanth

---

<div class="post-metadata">

**Author:** ![vasanthrajsp29](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/vasanthrajsp29/32/20713_2.png) [@vasanthrajsp29](https://developer.sailpoint.com/discuss/u/vasanthrajsp29)\
**Post date:** [June 26, 2024, 4:26pm UTC](https://developer.sailpoint.com/discuss/t/username-generator/69088/8 "2024-06-26T16:26:21Z")

</div>

Hi @bcariaga,

Its workday auth source.

Thanks!  
Vasanth

---

<div class="post-metadata">

**Author:** ![jishnu\_suresh](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/jishnu_suresh/32/20590_2.png) [@jishnu\_suresh](https://developer.sailpoint.com/discuss/u/jishnu_suresh)\
**Post date:** [June 26, 2024, 6:08pm UTC](https://developer.sailpoint.com/discuss/t/username-generator/69088/9 "2024-06-26T18:08:13Z")

</div>

Hi Vasanth,

As an alternate method, you can try to use the cloud rule. Please see the link below for an example.

> **[How to Search Non-Indexed Account Attributes in IDN Rules for Uniqueness](https://community.sailpoint.com/t5/IdentityNow-Wiki/How-to-Search-Non-Indexed-Account-Attributes-in-IDN-Rules-for/ta-p/205863)**
>
> This article will show how to use the recently released feature on creating indexed attributes which can be referenced in rules to do uniqueness searches and generate attributes like sAMAccountName / email / userPrincipalName etc. It allows you to...

---

<div class="post-metadata">

**Author:** ![KRM7](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/krm7/32/2685_2.png) [@KRM7](https://developer.sailpoint.com/discuss/u/KRM7)\
**Post date:** [June 26, 2024, 7:29pm UTC](https://developer.sailpoint.com/discuss/t/username-generator/69088/10 "2024-06-26T19:29:09Z")

</div>

Below is the sequence of operations.

1. You can have any value to the email identity attribute, it doesn’t need to be unique even. We can generate an email in a format

2. I believe you use AD, generate email at create account with uniqueness using the Generator as I have mentioned already.

3. You need to use FirstValid Transform for email attribute with below logic

- Get email from your AD source
- If not available, then generate using concat Transform

1. Once AD account is created, Identity updates with the mail from AD account
2. Enable attribute sync for you HR source using your mail attribute

Thanks  
Krish

---

<div class="post-metadata">

**Author:** ![vasanthrajsp29](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/vasanthrajsp29/32/20713_2.png) [@vasanthrajsp29](https://developer.sailpoint.com/discuss/u/vasanthrajsp29)\
**Post date:** [June 27, 2024, 1:47am UTC](https://developer.sailpoint.com/discuss/t/username-generator/69088/11 "2024-06-27T01:47:20Z")

</div>

This is noted, Thanks Krish

---

<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:** [August 26, 2024, 1:47am UTC](https://developer.sailpoint.com/discuss/t/username-generator/69088/12 "2024-08-26T01:47:50Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
