Transform error when using regex

Hello,

I’ve created a transform that should only change the domain name of the email address if the name starts with chris.jones or mark.jacobs. The error only appears if the account has an email address.
Any help would be appreciated.
Thanks!

Error:
There was an exception while calculating the value for this attribute. Error during transformation for attribute: email (Transform ID: Set Test Email Domain Transform) Cause: Error rendering template: ^(chris.jones|mark.jacobs)@.$*

Transform:

{
  "name": "Set Test Email Domain Transform",
  "type": "lower",
  "attributes": {
    "input": {
      "type": "replace",
      "attributes": {
        "regex": "^(chris.jones|mark.jacobs)@.*$",
        "replacement": "[email protected]",
        "input": {
          "type": "lower",
          "attributes": {
            "input": {
              "type": "accountAttribute",
              "attributes": {
                "sourceName": "Active Directory",
                "attributeName": "mail"
              }
            }
          }
        }
      }
    }
  }
}

Also tried escaping the “.” but still get the same error
"regex": "^(chris\\.jones|mark\\.jacobs)@.*$"

Hi Mario,

Greetings of the day!

Can you try below Json
image

Hi @GK91
Get this error when the regex was changed to
"regex": "^(chris\\\\.jones|mark\\\\.jacobs)@.*$",

Error rendering template: ^(chris\.jones|mark\.jacobs)@.*$

Hi @mario_rod
can you try this regex once ^(chris.jones|mark.jacobs)@[a-zA-Z0-9.-]+$

1 Like

@Tulasi still getting an error:

There was an exception while calculating the value for this attribute. Error during transformation for attribute: email (Transform ID: Set Test Email Domain Transform) Cause: Error rendering template: ^(chris.jones|mark.jacobs)@[a-zA-Z0-9.-]+$

Could it be compatibility issues betwee ISC/seaspray parser and regex?

Not having a solution, but had the same issue in the past and reverted to a different transform to achieve what I needed to achieve, but today ran into this same issue again with a simple regex “^Full time$”

Seems to be something wrong with this transform

yeah it’s looking more like the parser cannot parse std regex. It does not like the \ or ^

Hi @mario_rod,
I tested the transform you provided multiple times and noticed there seems to be an issue with the regex. After some trial and error, I made a few adjustments, and the following transform worked correctly for me.

{
  "name": "Set Test Email Domain Transform",
  "type": "lower",
  "attributes": {
    "input": {
      "type": "replace",
      "attributes": {
        "regex": "^(chris.jones|mark.jacobs)@.*",
        "replacement": "[email protected]",
        "input": {
          "type": "lower",
          "attributes": {
            "input": {
              "type": "accountAttribute",
              "attributes": {
                "sourceName": "Active Directory",
                "attributeName": "mail"
              }
            }
          }
        }
      }
    }
  }
}

If it worked please mark as solution.
Thank you!

1 Like

Hi @Abhishek_1995

This works but if the identity has an existing email attrib but does NOT have an AD account (mail attrib), it returns nothing. It wipes out the existing email attrib.

It needs to return the existing email attrib if AD/mail does not exist.

Hi @mario_rod,

I think for this you use first valid transfrom.

Thank you!

Hi @mario_rod,

Please try the below transform i checked it worked for me.

{
    "attributes": {
        "values": [
            {
                "type": "lower",
                "attributes": {
                    "input": {
                        "type": "replace",
                        "attributes": {
                            "regex": "^(chris.jones|mark.jacobs)@.*",
                            "replacement": "[email protected]",
                            "input": {
                                "type": "lower",
                                "attributes": {
                                    "input": {
                                        "type": "accountAttribute",
                                        "attributes": {
                                            "sourceName": "Active Directory",
                                            "attributeName": "mail"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            {
                "type": "accountAttribute",
                "attributes": {
                    "sourceName": "Delimited File HRMS",
                    "attributeName": "Email"
                }
            }
        ]
    },
    "type": "firstValid",
    "name": "Test First Valid Transform for mail"
}

Once it is resolved please do mark as solution.
Thank you!

Hi @Abhishek_1995 -
I actually did that and got it to work yesterday.
Forgot to post the solution here.
Thanks for the help!

1 Like