Split Transform that will give the job code

I we are passing the job code and title in one field over to SailPoint and I am trying to just get the job code and place in the job code Identity attribute. Below is the transform I wrote but it only works when the data is just for example 1170-LPN and when it is say this 1397-Respiratory Therapist-Non Union (CRT/RRT) it will not spilt the job code out.

< “name”: “PROD_Split_JobCode”,

"type": "static",

"attributes": {

    "employeeType": {

        "type": "accountAttribute",

        "attributes": {

            "sourceName": "PROD-Passport Database",

            "attributeName": "User_Type"

        }

    },

    "jobCode": {

        "type": "accountAttribute",

        "attributes": {

            "sourceName": "PROD-Passport Database",

            "attributeName": "Title"

        }

    },

    "value": "#set($jobCode = $jobCode)#if($jobCode)#set($parts = $jobCode.split(\\"-\\"))#if($parts.size() == 2)$parts.get(0).trim()#{else}$jobCode#end#{else}\\"blank\\"#end"

},

"internal": false

}>

Hey @dpowers1,

seems like you wanna fetch only the first part from the title. Give it try below

{
    "attributes": {
        "values": [
            {
                "attributes": {
                    "input": {
                        "attributes": {
                            "input": {
                                "attributes": {
                                    "sourceName": "PROD-Passport Database",
                                    "attributeName": "Title"
                                },
                                "type": "accountAttribute"
                            },
                            "delimiter": "-",
                            "index": 0,
                            "throws": false
                        },
                        "type": "split"
                    }
                },
                "type": "trim"
            },
            "blank"
        ]
    },
    "type": "firstValid",
    "name": "PROD_Split_JobCode"
}

thanks