Transform help needed

I’ve hit a wall with a transform. I tried using a conditional, but wasn’t getting anywhere - so I switched to a firstValid.

In short, I need the transform to return a blank value if both account attribute values are blank.

If either of them has data in it, I need that data returned (after being washed for ISO8601).

If both of them have data, I need the HR ORG SOURCE value to be returned.

Oh yeah, bad news, both are dates in slightly different formats which require some pretreatment to get them into ISO8601 - and the treatment isn’t the same.

Maybe there’s a whole other way.

{
    "name": "New Term Date",
    "type": "firstValid",
    "attributes": {
        "values": [
            {
                "attributes": {
                    "firstDate": {
                        "attributes": {
                            "input": {
                                "attributes": {
                                    "sourceName": "Workday HR",
                                    "attributeName": "LAST_DAY_OF_WORK"
                                },
                                "type": "accountAttribute"
                            },
                            "inputFormat": "MM/dd/yyyy",
                            "outputFormat": "ISO8601"
                        },
                        "type": "dateFormat"
                    }
                }
            },
            {
                "type": "dateFormat",
                "attributes": {
                    "input": {
                        "attributes": {
                            "input": {
                                "attributes": {
                                    "input": {
                                        "attributes": {
                                            "sourceName": "JDBC HR ORG",
                                            "attributeName": "D_TMN"
                                        },
                                        "type": "accountAttribute"
                                    },
                                    "regex": "(?=\\s).*",
                                    "replacement": ""
                                },
                                "type": "replace"
                            }
                        },
                        "type": "trim"
                    },
                    "inputFormat": "M/d/yyyy",
                    "outputFormat": "ISO8601"
                }
            }
        ],
        "ignoreErrors": true
    },
    "internal": false
}

Hi @rmccoy-unum,

Here’s the updated transform,

{
    "name": "New Term Date",
    "type": "firstValid",
    "attributes": {
        "values": [
            {
                "attributes": {
                    "attributes": {
                        "input": {
                            "attributes": {
                                "sourceName": "Workday HR",
                                "attributeName": "LAST_DAY_OF_WORK"
                            },
                            "type": "accountAttribute"
                        },
                        "inputFormat": "MM/dd/yyyy",
                        "outputFormat": "ISO8601"
                    },
                    "type": "dateFormat"
                }
            },
            {
                "type": "dateFormat",
                "attributes": {
                    "input": {
                        "attributes": {
                            "input": {
                                "attributes": {
                                    "input": {
                                        "attributes": {
                                            "sourceName": "JDBC HR ORG",
                                            "attributeName": "D_TMN"
                                        },
                                        "type": "accountAttribute"
                                    },
                                    "regex": "(?=\s).*",
                                    "replacement": ""
                                },
                                "type": "replace"
                            }
                        },
                        "type": "trim"
                    },
                    "inputFormat": "M/d/yyyy",
                    "outputFormat": "ISO8601"
                }
            },
            null
        ],
        "ignoreErrors": true
    },
    "internal": false
}

I actually don’t understand your "regex": "(?=\s).*",. Could you please confirm that before you add this transform.
Hope this helps!

If you want the "sourceName": "JDBC HR ORG", as the priority, just move this part of the transform above "sourceName": "Workday HR",

You can use this discussion as a reference - Transform to return NULL

Looking at your transform, you may need to change the order in the first valid on your existing sources and also add the blank value at the end of firstValid with empty double quotes.
In firstValid transform,

  1. First value should be calculated from HR ORG SOURCE, I believe it is JDBC HR ORG in your transform
  2. Second Value should be from the source Workday HR
  3. Third value, is a static transform with “”. You can test this value by adding some default values instead of empty quotes like “none”
{
    "name": "New Term Date",
    "type": "firstValid",
    "attributes": {
        "values": [
		{
                "type": "dateFormat",
                "attributes": {
                    "input": {
                        "attributes": {
                            "input": {
                                "attributes": {
                                    "input": {
                                        "attributes": {
                                            "sourceName": "JDBC HR ORG",
                                            "attributeName": "D_TMN"
                                        },
                                        "type": "accountAttribute"
                                    },
                                    "regex": "(?=\\s).*",
                                    "replacement": ""
                                },
                                "type": "replace"
                            }
                        },
                        "type": "trim"
                    },
                    "inputFormat": "M/d/yyyy",
                    "outputFormat": "ISO8601"
                }
            },
            {
                "attributes": {
                    "firstDate": {
                        "attributes": {
                            "input": {
                                "attributes": {
                                    "sourceName": "Workday HR",
                                    "attributeName": "LAST_DAY_OF_WORK"
                                },
                                "type": "accountAttribute"
                            },
                            "inputFormat": "MM/dd/yyyy",
                            "outputFormat": "ISO8601"
                        },
                        "type": "dateFormat"
                    }
                }
            },
	""
        ],
        "ignoreErrors": true
    },
    "internal": false
}

I Have not tested it but may be you can do something like this:

{
    "id": "",
    "name": "",
    "type": "static",
    "attributes": {
        "firstAttributeValue": {
            "attributes": {
                "values": [
                    {
                        "attributes": {
                            "sourceName": "HR",
                            "attributeName": "firstAttribute"
                        },
                        "type": "accountAttribute"
                    },
                    {
                        "attributes": {
                            "value": "firstValue"
                        },
                        "type": "static",
                        "name": "Static Transform"
                    }
                ]
            },
            "type": "firstValid",
            "name": "firstValid2"
        },
        "secondAttributeValue": {
            "attributes": {
                "values": [
                    {
                        "attributes": {
                            "sourceName": "HR",
                            "attributeName": "secondAttribute"
                        },
                        "type": "accountAttribute"
                    },
                    {
                        "attributes": {
                            "value": "secondValue"
                        },
                        "type": "static",
                        "name": "Static Transform2"
                    }
                ]
            },
            "type": "firstValid",
            "name": "firstValid1"
        },
        "HRORGSOURCE":                    {
            "attributes": {
                "sourceName": "HR",
                "attributeName": "Org_Source"
            },
            "type": "accountAttribute"
        },
        "value": "#if($firstAttributeValue=='firstValue' && $secondAttributeValue=='secondValue')''#elseif($firstAttributeValue=='firstValue' && $secondAttributeValue!='secondValue')$firstAttributeValue#elseif($firstAttributeValue!='firstValue' && $secondAttributeValue=='secondValue')$secondAttributeValue#elseif($firstAttributeValue!='firstValue' && $secondAttributeValue!='secondValue')$HRORGSOURCE##end"
    },
    "internal": false
}

Hi @rmccoy-unum ,
Did any of these work for you? If yes, please mark that post as the solution :slight_smile:

We got it sorted with the following.

{
    "id": "xxxxxxxxxxxxxxxxxxxxxxxxx",
    "name": "New Term Date",
    "type": "firstValid",
    "attributes": {
        "values": [
            {
                "type": "dateFormat",
                "attributes": {
                    "input": {
                        "attributes": {
                            "sourceName": "Workday HR",
                            "attributeName": "LAST_DAY_OF_WORK"
                        },
                        "type": "accountAttribute"
                    },
                    "inputFormat": "MM/dd/yyyy",
                    "outputFormat": "ISO8601"
                }
            },
            {
                "type": "dateFormat",
                "attributes": {
                    "input": {
                        "attributes": {
                            "input": {
                                "attributes": {
                                    "input": {
                                        "attributes": {
                                            "sourceName": "JDBC HR ORG",
                                            "attributeName": "D_TMN"
                                        },
                                        "type": "accountAttribute"
                                    },
                                    "regex": "(?=\\s).*",
                                    "replacement": ""
                                },
                                "type": "replace"
                            }
                        },
                        "type": "trim"
                    },
                    "inputFormat": "M/d/yyyy",
                    "outputFormat": "ISO8601"
                }
            }
        ],
        "ignoreErrors": true
    },
    "internal": false
}
1 Like

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