Email transform

I’m having difficulty creating a “transform” to use the mail attribute of a source (open)Condition : Populate Alternate email from DAP - if Email value is undefined then do not display anything otherwise dispaly the email.Here is I tied . can any one help me

Hi @polaraojalligampala,

Can you try this :

{
    "attributes": {
        "alternateEmail": {
            "attributes": {
                "sourceName": "openLDAP",
                "attributeName": "personalMail"
            },
            "type": "accountAttribute"
        },
        "value": "#if($alternateEmail && $alternateEmail!='')$alternateEmail#end"
    },
    "type": "static",
    "name": "Generate alternate Mail Transform-Sandbox"
}

Hi @polaraojalligampala,

You can make use of a simple first valid transform as below :

{
    "name": "Generate alternate Mail Transform-Sandbox",
    "type": "firstValid",
    "attributes": {
        "values": [
            {
                "attributes": {
                    "attributeName": "personalMail",
                    "sourceName": "openLDAP"
                },
                "type": "accountAttribute"
            },
            {
                "attributes": {
                    "value": ""
                },
                "type": "static"
            }
        ]
    },
    "internal": false
}
2 Likes

Hi @polaraojalligampala,

Try to use below given. Also, you can make changes in the first valid solution by addition of ignoreError and then try.

{
    "attributes": {
        "alternateEmail": {
            "attributes": {
                "ignoreErrors": "true",
                "values": [
                    {
                        "attributes": {
                            "sourceName": "openLDAP",
                            "attributeName": "personalMail"
                        },
                        "type": "accountAttribute"
                    },
                    {
                        "attributes": {
                            "value": "none"
                        },
                        "type": "static"
                    }
                ]
            },
            "type": "firstValid"
        },
        "value": "#if($alternateEmail!='none')$alternateEmail#end"
    },
    "type": "static",
    "name": "Email Transform"
}

If further help needed, then let me know.

Thanks

Expanding on @ashutosh08’s reply… there needs to be an else statement. With the current logic, if the user does not have an attribute for personalMail on the openLDAP source, the firstValid transform will result in none for alternateEmail. Then, the VTL logic will result in a null value.

Try one of these:

FirstValid & Static

{
    "attributes": {
        "alternateEmail": {
            "attributes": {
                "values": [
                    {
                        "attributes": {
                            "attributeName": "personalMail",
                            "sourceName": "openLDAP"
                        },
                        "type": "accountAttribute"
                    },
                    "None"
                ]
            },
            "type": "firstValid"
        },
        "value": "#if($alternateEmail!='None')$alternateEmail#{else}None#end"
    },
    "type": "static",
    "name": "Email Transform"
}

FirstValid Only

{
    "attributes": {
        "values": [
            {
                "attributes": {
                    "attributeName": "personalMail",
                    "sourceName": "openLDAP"
                },
                "type": "accountAttribute"
            },
            "None"
        ]
    },
    "type": "firstValid",
    "name": "Email Transform"
}
1 Like

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