Help me write a trasnform that will generate email for two different sources one is (userId)(uniquecounter)@domain.com and for all other sources is other is (initialoffname)(lastname)(uniquecounter)@domain.com

Hey guys i need a trasnform for email geenration in ad prov policy based on two different sources :

1st source : it should create (userId)(uniquecounter)@domain.com else create for all other sources as
(initialoffname)(lastname)(uniquecounter)@domain.com
tried below but not working

{
    "name": "mail",
    "transform": {
      "type": "usernameGenerator",
      "attributes": {
        "sourceCheck": true,
        "patterns": [
          "$initials$ln@$domain",
          "$initials$ln${uniqueCounter}@$domain"
        ],
        "initials": {
          "type": "identityAttribute",
          "attributes": {
            "name": "inititalforaddisplayname"
          }
        },
        "ln": {
          "type": "identityAttribute",
          "attributes": {
            "name": "lname"
          }
        },
        "domain": {
          "type": "identityAttribute",
          "attributes": {
            "name": "domainbasedontenant"
          }
        }
      }
    },
    "attributes": {
      "cloudMaxSize": "100",
      "cloudMaxUniqueChecks": "5",
      "cloudRequired": "true"
    },
    "isRequired": false,
    "type": "string",
    "isMultiValued": false
  }```

change this to

"domain": {
  "type": "concat",
  "attributes": {
           "values": [
              "@",
              {
                   "type": "identityAttribute",
                   "attributes": {
                             "name": "domainbasedontenant"
                   }
              }
        ]
  }

and try after removing @ from pattern strings

ok but for other source we need patter like (userId)(uniquecounter)@domain.com what to do ? @iamology

@iamology is the below one good

{
    "name": "mail",
    "transform": {
      "type": "usernameGenerator",
      "attributes": {
        "sourceCheck": true,
        "patterns": [
          "$initials.$ln@$domain",
          "$initials.$ln.${uniqueCounter}@$domain"
        ],
        "initials": {
          "type": "identityAttribute",
          "attributes": {
            "name": "inititalforaddisplayname"
          }
        },
        "ln": {
          "type": "identityAttribute",
          "attributes": {
            "name": "lname"
          }
        },
       "domain": {
  "type": "concat",
  "attributes": {
           "values": [
              "@",
              {
                   "type": "identityAttribute",
                   "attributes": {
                             "name": "domainbasedontenant"
                   }
              }
        ]
    },
    "attributes": {
      "cloudMaxSize": "100",
      "cloudMaxUniqueChecks": "5",
      "cloudRequired": "true"
    },
    "isRequired": false,
    "type": "string",
    "isMultiValued": false
  }

remove @ from here as it’s already included in $domain.

Reason behind my earlier suggestion is that @ is a key character and will create error when used in a velocity template