Transform is failing when externalcompany_Name is blank

I have this transform and it is failing if the externalcompany_name is blank coming from the source.

{

"id": "1b7380a0-fa1f-479e-a22c-49ea2bf474c3",

"name": "SB_OFFICE_SET",

"type": "static",

"attributes": {

    "userType": {

        "type": "accountAttribute",

        "attributes": {

            "sourceName": "ARHSB-Passport Database",

            "attributeName": "User_Type"

        }

    },

    "jobTitle": {

        "type": "accountAttribute",

        "attributes": {

            "sourceName": "ARHSB-Passport Database",

            "attributeName": "Title"

        }

    },

    "arhFacility": {

        "type": "split",

        "attributes": {

            "input": {

                "type": "accountAttribute",

                "attributes": {

                    "sourceName": "ARHSB-Passport Database",

                    "attributeName": "ARH_Facility"

                }

            },

            "delimiter": "-",

            "index": 1

        }

    },

    "extCompany": {

        "type": "accountAttribute",

        "attributes": {

            "sourceName": "ARHSB-Passport Database",

            "attributeName": "ExternalCompany_Name"

        }

    },

    "ARHstatic": {

        "attributes": {

            "value": "Appalachian Regional Healthcare, Inc."

        },

        "type": "static"

    },

    "value": "#if($userType.toLowerCase().trim() == 'student - medical')$ARHstatic#elseif($userType.toLowerCase().trim() == 'student' || $userType.toLowerCase().trim() == 'student - nursing' || $userType.toLowerCase().trim() == 'student - pharmacy' || $userType.toLowerCase().trim() == 'student - pt/ot' || $userType.toLowerCase().trim() == 'student - pt/ot/slp' || $userType.toLowerCase().trim() == 'contractlabor' || $jobTitle.toLowerCase().trim() == '9905-external - provider')$arhFacility#{else}$extCompany#end"

},

"internal": false

}

Depending on your intention on how to handle this part, you could just use a first valid block for “extCompany”

When using variables in the static transform, if the value is NULL or an empty string, the transform will fail to resolve. It is best practice to use a firstValid transform and add variable validation into the velocity string like so:

{
    "id": "1b7380a0-fa1f-479e-a22c-49ea2bf474c3",
    "name": "SB_OFFICE_SET",
    "type": "static",
    "attributes": {
        "userType": {
            "type": "accountAttribute",
            "attributes": {
                "sourceName": "ARHSB-Passport Database",
                "attributeName": "User_Type"
            }
        },
        "jobTitle": {
            "type": "accountAttribute",
            "attributes": {
                "sourceName": "ARHSB-Passport Database",
                "attributeName": "Title"
            }
        },
        "arhFacility": {
            "type": "split",
            "attributes": {
                "input": {
                    "type": "accountAttribute",
                    "attributes": {
                        "sourceName": "ARHSB-Passport Database",
                        "attributeName": "ARH_Facility"
                    }
                },
                "delimiter": "-",
                "index": 1
            }
        },
        "extCompany": {
            "type": "firstValid",
            "attributes": {
                "values": [
                    {
                        "type": "accountAttribute",
                        "attributes": {
                            "sourceName": "ARHSB-Passport Database",
                            "attributeName": "ExternalCompany_Name"
                        }
                    },
                    "null"
                ]
            }
        },
        "ARHstatic": {
            "attributes": {
                "value": "Appalachian Regional Healthcare, Inc."
            },
            "type": "static"
        },
        "value": "#if($userType.toLowerCase().trim() == 'student - medical')$ARHstatic#elseif($userType.toLowerCase().trim() == 'student' || $userType.toLowerCase().trim() == 'student - nursing' || $userType.toLowerCase().trim() == 'student - pharmacy' || $userType.toLowerCase().trim() == 'student - pt/ot' || $userType.toLowerCase().trim() == 'student - pt/ot/slp' || $userType.toLowerCase().trim() == 'contractlabor' || $jobTitle.toLowerCase().trim() == '9905-external - provider')$arhFacility#{else}#if($extCompany != 'null')$extCompany#end#end"
    },
    "internal": false
}

I’d recommend this logic as a precautionary measure to each of the variables in a static transform.