Transforms logic fixing

Hi Experts,

There are few users having dash on their workday attribute - workTelephone, where for few users, there is no dash in workTelephone and for few users there is no value on the attribute.

There are three sample input :

1st → +1 (702) 634-7330
2nd → +1 (702) 8234108
3rd → No value.

I want to write a tranform, to see if phone number has dash, then return phone number, if phone number not having dash, then return the reference transform.when there is no value It has to return empty string. Please find the tranform below. I’m getting error on identities who has no value on work Phone attribute.

can anyone help me resolving it.

{
    "name": "IH - put dash",
    "type": "static",
    "attributes": {
        "phoneSub": {
            "attributes": {
                "input": {
                    "attributes": {
                        "attributeName": "WORK_TELEPHONE",
                        "sourceName": "Workday Sandbox"
                    },
                    "type": "accountAttribute"
                },
               "begin": 12,
				"end": 13 
            },
            "type": "substring",
        },
		"workPhone": {
            "attributes": {
                "attributeName": "WORK_TELEPHONE",
                "sourceName": "Workday Sandbox"
            },
            "type": "accountAttribute"
        },
		"phoneString": {
                "attributes": {
                    "id": "IH - set Dash TEXT"
                },
                "type": "reference"
            },
        
        "value": "#if($phoneSub == '-')$workPhone#{else}$phoneString#end"
    },
    "internal": false
}


.....................................................
reference transform : 
{
		"name": "IH - set Dash TEXT"
            "attributes": {
                "values": [
                    {
                    "attributes": {
						"input": {
						"attributes": {
                        "attributeName": "WORK_TELEPHONE",
                        "sourceName": "Workday Sandbox"
                    },
                    "type": "accountAttribute"
					},
					"begin": 0,
					"end": 12
                    },
					"type": "substring"
                    },
                    {
                        "attributes": {
                            "value": "-"
                        },
                        "type": "static"
                    },
                    {
                    "attributes": {
						"input": {
						"attributes": {
                        "attributeName": "WORK_TELEPHONE",
                        "sourceName": "Workday Sandbox"
                    },
                    "type": "accountAttribute"
					},
					"begin": 12
					
                    },
					"type": "substring"
                    }
                ]
            },
            "type": "concat",
			"internal": false
}

Welcome to the developer community Chandra,

When writing a transform that needs to handle attributes that might be null/empty, it is advisable to use the first valid operation so your transform doesn’t error out due to a null pointer exception. First valid will allow you to capture the null input and process it as you see fit.

@colin_mckibben

I tried first valid operation and it worked ignoring the null value.

Thanks.

1 Like