usernameGenarator

Hi everyone,

I’m traing to create a transformation, using the example in the documentation for transform usernameGenerator: Username Generator | SailPoint Developer Community
The code examplo that I’m using:

{
    "attributes": {
      "cloudMaxSize": "100",
      "cloudMaxUniqueChecks": "9",
      "cloudRequired": "true"
    },
    "isRequired": false,    
    "multi": false,
    "name": "criaEmailTerceiro",
    "transform": {
      "type": "usernameGenerator",
      "attributes": {
        "sourceCheck": true,
        "patterns": [
            "[email protected]",
            "[email protected]",
            "[email protected]",
            "[email protected]",
            "$terc$f1.$ln{uniqueCounter}@dominio.com.br"
        ],
        "f1": {
            "type": "lower",
            "attributes": {
                "input": {
                    "attributes": {
                        "begin": 0,
                        "end": 1,
                        "input": {
                            "type": "accountAttribute",
                            "attributes": {
                                "sourceName": "Base",
                                "attributeName": "NOME"
                            }
                        }
                    },
                    "type": "substring"
                }
            }
        },
        "f2": {
            "type": "lower",
            "attributes": {
                "input": {
                    "attributes": {
                        "begin": 0,
                        "end": 2,
                        "input": {
                            "type": "accountAttribute",
                            "attributes": {
                                "sourceName": "Base",
                                "attributeName": "NOME"
                            }
                        }
                    },
                    "type": "substring"
                }
            }
        },
        "f3": {
            "type": "lower",
            "attributes": {
                "input": {
                    "attributes": {
                        "begin": 0,
                        "end": 1,
                        "input": {
                            "type": "accountAttribute",
                            "attributes": {
                                "sourceName": "Base",
                                "attributeName": "NOME_DO_MEIO"
                            }
                        }
                    },
                    "type": "substring"
                }
            }
        },
        "ln": {
            "type": "lower",
            "attributes": {
                "input": {
                    "type": "accountAttribute",
                    "attributes": {
                        "sourceName": "Base",
                        "attributeName": "ULTIMO_SOBRENOME"
                    }
                }
            }
        },
        "terc": {
            "type": "static",
            "attributes": {
                "value": "terceiro-"
            }
        }
        }
    },
    "type": "usernameGenerator"
  }

But when I save it looks like this after I save the transformation:
This is the code after that I saved:

{
    "id": "For security I change this ID",
    "name": "criaEmailTerceiro",
    "type": "usernameGenerator",
    "attributes": {
        "cloudMaxSize": "100",
        "cloudMaxUniqueChecks": "9",
        "cloudRequired": "true"
    },
    "internal": false
}

Anybody could be help me to identify this problem and solve?

thank you very much in advance

Hello @reinajss,

The transform looks valid.

The usernameGenerator transform is meant to be used during account creation, so it would be attached to an account create provisioning policy.

The body of the request would look something like below

{
  "name": "Account Creation Policy",
  "description": "Create Account Policy",
  "usageType": "CREATE",
  "fields": [
    {
      "attributes": {
        "cloudMaxSize": "100",
        "cloudMaxUniqueChecks": "9",
        "cloudRequired": "true"
      },
      "isRequired": false,
      "multi": false,
      "name": "criaEmailTerceiro",
      "transform": {
        "type": "usernameGenerator",
        "attributes": {
          "sourceCheck": true,
          "patterns": [
            "[email protected]",
            "[email protected]",
            "[email protected]",
            "[email protected]",
            "$terc$f1.$ln{uniqueCounter}@dominio.com.br"
          ],
          "f1": {
            "type": "lower",
            "attributes": {
              "input": {
                "attributes": {
                  "begin": 0,
                  "end": 1,
                  "input": {
                    "type": "accountAttribute",
                    "attributes": {
                      "sourceName": "Base",
                      "attributeName": "NOME"
                    }
                  }
                },
                "type": "substring"
              }
            }
          },
          "f2": {
            "type": "lower",
            "attributes": {
              "input": {
                "attributes": {
                  "begin": 0,
                  "end": 2,
                  "input": {
                    "type": "accountAttribute",
                    "attributes": {
                      "sourceName": "Base",
                      "attributeName": "NOME"
                    }
                  }
                },
                "type": "substring"
              }
            }
          },
          "f3": {
            "type": "lower",
            "attributes": {
              "input": {
                "attributes": {
                  "begin": 0,
                  "end": 1,
                  "input": {
                    "type": "accountAttribute",
                    "attributes": {
                      "sourceName": "Base",
                      "attributeName": "NOME_DO_MEIO"
                    }
                  }
                },
                "type": "substring"
              }
            }
          },
          "ln": {
            "type": "lower",
            "attributes": {
              "input": {
                "type": "accountAttribute",
                "attributes": {
                  "sourceName": "Base",
                  "attributeName": "ULTIMO_SOBRENOME"
                }
              }
            }
          },
          "terc": {
            "type": "static",
            "attributes": {
              "value": "terceiro-"
            }
          }
        }
      },
      "type": "usernameGenerator"
    },
    {
      "name": "email",
      "transform": {
        "type": "identityAttribute",
        "attributes": {
          "name": "email"
        }
      },
      "attributes": {},
      "isRequired": false,
      "type": "string",
      "isMultiValued": false
    },
    {
      "name": "displayName",
      "transform": {
        "type": "identityAttribute",
        "attributes": {
          "name": "displayName"
        }
      },
      "attributes": {},
      "isRequired": false,
      "type": "string",
      "isMultiValued": false
    }
  ]
}

Thank you for your help, I create this policy, but I have a question. Every time a new identity is created in this profile will this policy run and the email will be calculated and created without the risk of duplicated it?

Yes, when a new Identity is created this will run and will create a unique username under the attribute criaEmailTerceiro.

The usernameGenerator will traverse through your patterns list until it has a unique username that is not being used.

Hi Tyler,

I was reading about this transformation process, and I noticed that referring to usernameGenerator on the website it says: “The generator only checks the accountID.” And so I won’t be able to use this process.
I wanted to know if it is possible to create this validation process in another way, that is, create a validation if the email already exists in the IDNow base, and if it exists, use the other way as we did here:" “$terc$f1$ln@ domain.com.br”,
[email protected]”,
[email protected]”,
[email protected]”,
$terc$f1.$ln{uniqueCounter}@dominio.com.br”", is it possible to do this without using usernameGenerator?

I am very grateful for your help.