Transform - Split and Sort Value

Hi there,

I need to sort a valid ID and split.

I’ve already had this transform to sort:

{
    "id": "082d",
    "name": "BTG-Sort-AreaIDSAP",
    "type": "firstValid",
    "attributes": {
        "values": [
            {
                "attributes": {
                    "sourceName": "Authoritative Source",
                    "attributeName": "DescArea",
                    "accountSortAttribute": "Order",
                    "accountSortDescending": true,
                    "accountReturnFirstLink": true
                },
                "type": "accountAttribute"
            }
        ]
    },
    "internal": false
}

And this to split:

{
    "id": "7b7838388",
    "name": "BTG-Split-AreaIDSAP",
    "type": "split",
    "attributes": {
        "delimiter": "-",
        "index": 0
    },
    "internal": false
}

Basically, I need to unite both.

Which do you want to happen first? The split or the sort?

Also: your firstValid for the sort transform appears to be missing a second value to use if the accountAttribute isn’t populated. Is this intentional?

First I need to sort, then split.

Is this not intentional, if missing can be null.

Try this

{
  "id": "xxxxxxxxxxxxxxxx",
  "name": "Transform",
  "type": "split",
  "attributes": {
    "input": {
      "type": "firstValid",
      "attributes": {
        "ignoreErrors": true,
        "values": [
          {
            "attributes": {
              "sourceName": "Authoritative Source",
              "attributeName": "DescArea",
              "accountSortAttribute": "Order",
              "accountSortDescending": true,
              "accountReturnFirstLink": true
            },
            "type": "accountAttribute"
          },
          "NONE-NONE"
        ]
      }
    },
    "delimiter": "-",
    "index": 0
  },
  "internal": false
}

Note: Need to be tested

1 Like

It looks like the documentation for the split transform primitive is missing its mention of the optional input attribute, but you should be able to add input within attributes (see the example in the transform documentation) and nest your firstValid transform within that.

2 Likes

Thanks everyone,

I tried this and worked:

{
    "id": "",
    "name": "",
    "type": "split",
    "attributes": {
        "delimiter": "-",
        "index": 0,
        "throw": true,
        "input": {
            "attributes": {
                "values": [
                    {
                        "attributes": {
                            "name": "departmentad"
                        },
                        "type": "identityAttribute"
                    }
                ]
            },
            "type": "firstValid"
        }
    },
    "internal": false
}

If there is any possibility that the attribute ‘departmentad’ could be null, I highly recommend putting in a value into the firstValid to catch this. As Gourab suggested ‘None-None’ would prevent any errors from occurring

1 Like