# Difficulty creating transform with concat + table and velocity

**URL:** <https://developer.sailpoint.com/discuss/t/difficulty-creating-transform-with-concat-table-and-velocity/95890>\
**Category:** SHF Discussion and Questions\
**Tags:** transforms, identity-security-cloud, provisioning\
**Created:** [January 3, 2025, 2:49pm UTC](https://developer.sailpoint.com/discuss/t/difficulty-creating-transform-with-concat-table-and-velocity/95890 "2025-01-03T14:49:43Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![raibom](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/raibom/32/9517_2.png) [@raibom](https://developer.sailpoint.com/discuss/u/raibom)\
**Post date:** [January 3, 2025, 2:49pm UTC](https://developer.sailpoint.com/discuss/t/difficulty-creating-transform-with-concat-table-and-velocity/95890/1 "2025-01-03T14:49:43Z")

</div>

Basically I need a transform that will be a concat of the company acronym + employee registration number.

It doesn’t happen that the acronym will change according to the registration number. I’m trying the way below but it gives an error in the print screen.

```auto
{
    "name": "BI_COLIGADA_PREFIXO_V11.7",
    "type": "concat",
    "attributes": {
        "values": [
            {
                "attributes": {
                    "siglaEmpresa":{
                        "type": "lookup",
                        "input": {
                        "attributes": {
                            "attributeName": "NOME_EMPRESA",
                            "sourceName": "TOTVS - Autoritativo"
                        },
                        "type": "accountAttribute"
                        },
                        "table": {
                            "Company 1": "BI",
                            "Company 2": "DM",
                            "Company 3": "DT",
                            "Company 4": "FR",
                        }
                    },
                    "chapa":{
                        "type": "accountAttribute",
                        "attributes": {
                            "attributeName": "CHAPA",
                            "sourceName": "TOTVS - Autoritativo"
                        }
                    },
                    "value": "#if($chapa>9999)'BT'#{else}$siglaEmpresa"
                }
            },
            {
                "attributes": {
                    "padding": "0",
                    "length": "6",
                    "input": {
                        "type": "accountAttribute",
                        "attributes": {
                            "attributeName": "CHAPA",
                            "sourceName": "TOTVS - Autoritativo"
                        }
                    }
                },
                "type": "leftPad"
            }
        ]
    },
    "internal": false
}

```

 ![image](https://global.discourse-cdn.com/sailpoint/original/3X/2/0/2043e7125d266c0f01d80db73c494a8a1be6670c.png)

---

<div class="post-metadata">

**Author:** ![PhilRawlings1](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/philrawlings1/32/37266_2.png) [@PhilRawlings1](https://developer.sailpoint.com/discuss/u/PhilRawlings1)\
**Post date:** [January 3, 2025, 3:01pm UTC](https://developer.sailpoint.com/discuss/t/difficulty-creating-transform-with-concat-table-and-velocity/95890/2 "2025-01-03T15:01:21Z")

</div>

Hi Bruno,  
You don’t need the “attributes”:{} that is inside the first part of the concat.  
Beyond that, I recommend that you build the transform slowly and in stages.

Try this as your first stage:

```auto
{
  "name": "BI_COLIGADA_PREFIXO_V11.7",
  "type": "firstValid",
  "attributes": {
    "values": [
      {
        "siglaEmpresa": {
          "type": "lookup",
          "input": {
            "type": "accountAttribute",
            "attributes": {
              "attributeName": "NOME_EMPRESA",
              "sourceName": "TOTVS - Autoritativo"
            }
          },
          "table": {
            "Company 1": "BI",
            "Company 2": "DM",
            "Company 3": "DT",
            "Company 4": "FR",
            "default": "XXX1"
          }
        }
      },
      "XXX2"
    ]
  }
}

```

---

<div class="post-metadata">

**Author:** ![JackSparrow](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/jacksparrow/32/19685_2.png) [@JackSparrow](https://developer.sailpoint.com/discuss/u/JackSparrow)\
**Post date:** [January 3, 2025, 3:30pm UTC](https://developer.sailpoint.com/discuss/t/difficulty-creating-transform-with-concat-table-and-velocity/95890/3 "2025-01-03T15:30:12Z")

</div>

Hi @raibom , transform type should be static as per the velocity condition given. Also, you can use “leftpad” transform in the same “chapa” attribute transform instead of doing it separately.

---

<div class="post-metadata">

**Author:** ![GOKUL\_ANANTH\_M](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/gokul_ananth_m/32/14416_2.png) [@GOKUL\_ANANTH\_M](https://developer.sailpoint.com/discuss/u/GOKUL_ANANTH_M)\
**Post date:** [January 3, 2025, 7:57pm UTC](https://developer.sailpoint.com/discuss/t/difficulty-creating-transform-with-concat-table-and-velocity/95890/4 "2025-01-03T19:57:10Z")

</div>

Hi @raibom ,

Try the below transform.

```auto
{
    "name": "BI_COLIGADA_PREFIXO_V11.7",
    "type": "concat",
    "attributes": {
        "values": [
            {
                "type": "static",
                "attributes": {
                    "siglaEmpresa": {
                        "type": "lookup",
                        "attributes": {
                            "input": {
                                "type": "accountAttribute",
                                "attributes": {
                                    "sourceName": "TOTVS - Autoritativo",
                                    "attributeName": "NOME_EMPRESA"
                                }
                            },
                            "table": {
                                "Company 1": "BI",
                                "Company 2": "DM",
                                "Company 3": "DT",
                                "Company 4": "FR",
                                "default": "ABC"
                            }
                        }
                    },
                    "chapa": {
                        "type": "accountAttribute",
                        "attributes": {
                            "sourceName": "TOTVS - Autoritativo",
                            "attributeName": "CHAPA"
                        }
                    },
                    "value": "#if($chapa>9999)'BT'#{else}$siglaEmpresa#end"
                }
            },
            {
                "type": "leftPad",
                "attributes": {
                    "padding": "0",
                    "length": "6",
                    "input": {
                        "type": "accountAttribute",
                        "attributes": {
                            "sourceName": "TOTVS - Autoritativo",
                            "attributeName": "CHAPA"
                        }
                    }
                }
            }
        ]
    }
}

```

Thanks!

---

<div class="post-metadata">

**Author:** ![raibom](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/raibom/32/9517_2.png) [@raibom](https://developer.sailpoint.com/discuss/u/raibom)\
**Post date:** [January 3, 2025, 8:25pm UTC](https://developer.sailpoint.com/discuss/t/difficulty-creating-transform-with-concat-table-and-velocity/95890/5 "2025-01-03T20:25:11Z")

</div>

I had 2 problems, the first was that I had to use the type: “static” and I didn’t know that.  
Second, I was missing the #end in the velocity template.  
After correcting it, it looked like this:

```auto
{
    "name": "BI_COLIGADA_PREFIXO_V11.14",
    "type": "concat",
    "attributes": {
        "values": [
            {
                "type": "static",
                "attributes": {
                    "companyAcronym": {
                        "type": "lookup",
                        "attributes": {
                            "input": {
                                "attributes": {
                                    "attributeName": "NOME_EMPRESA",
                                    "sourceName": "TOTVS - Autoritativo"
                                },
                                "type": "accountAttribute"
                            },
                            "table": {
                                "Company 1": "BI",
                                "Company 2": "DM",
                                "Company 3": "DT",
                                "Company 4": "FR",
                                "default": "XXX1"
                            }
                        }
                    },
                    "employeeNumber": {
                        "type": "accountAttribute",
                        "attributes": {
                            "attributeName": "CHAPA",
                            "sourceName": "TOTVS - Autoritativo"
                        }
                    },
                    "value": "#if($employeeNumber>9999)'BT'#{else}$companyAcronym#end"
                }
            },
            {
                "type": "leftPad",
                "attributes": {
                    "padding": "0",
                    "length": "6",
                    "input": {
                        "type": "accountAttribute",
                        "attributes": {
                            "attributeName": "CHAPA",
                            "sourceName": "TOTVS - Autoritativo"
                        }
                    }
                }
            }
        ]
    },
    "internal": false
}

```

Now I’m trying to remove the leftPad operation, doing it directly in velocity but I’m having problems. I tried this way using copilot but it gave an error as shown in the print screen:

Template: _`#if($employeeNumber>9999)'BT' + $employeeNumber.pad(6, '0')#{else}$companyAcronym + $employeeNumber.pad(6, '0')#end`_

 ![image](https://global.discourse-cdn.com/sailpoint/original/3X/2/c/2c6d4ed7d8f31a0da1a1cb66850fade6842bfb11.png)

---

<div class="post-metadata">

**Author:** ![JackSparrow](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/jacksparrow/32/19685_2.png) [@JackSparrow](https://developer.sailpoint.com/discuss/u/JackSparrow)\
**Post date:** [January 4, 2025, 4:26am UTC](https://developer.sailpoint.com/discuss/t/difficulty-creating-transform-with-concat-table-and-velocity/95890/6 "2025-01-04T04:26:52Z")

</div>

Hi @raibom, can you get us one example with the use case what exactly you are trying to do? It will be helpful for us to help you with the transform.

---

<div class="post-metadata">

**Author:** ![GOKUL\_ANANTH\_M](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/gokul_ananth_m/32/14416_2.png) [@GOKUL\_ANANTH\_M](https://developer.sailpoint.com/discuss/u/GOKUL_ANANTH_M)\
**Post date:** [January 4, 2025, 10:40am UTC](https://developer.sailpoint.com/discuss/t/difficulty-creating-transform-with-concat-table-and-velocity/95890/7 "2025-01-04T10:40:36Z")

</div>

Hi @raibom ,

I have a question, like why are you moving it inside static method?

Is the above given transform, didn’t satisfy any requirements?

---

<div class="post-metadata">

**Author:** ![raibom](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/raibom/32/9517_2.png) [@raibom](https://developer.sailpoint.com/discuss/u/raibom)\
**Post date:** [January 4, 2025, 2:42pm UTC](https://developer.sailpoint.com/discuss/t/difficulty-creating-transform-with-concat-table-and-velocity/95890/8 "2025-01-04T14:42:58Z")

</div>

@JackSparrow , What I want now is to do the left padding directly in velocity. As I showed in the last example, sailpoint doesn’t seem to recognize this _ **.pad** _ method.  
I would like to know if this is possible.

---

<div class="post-metadata">

**Author:** ![raibom](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/raibom/32/9517_2.png) [@raibom](https://developer.sailpoint.com/discuss/u/raibom)\
**Post date:** [January 4, 2025, 2:44pm UTC](https://developer.sailpoint.com/discuss/t/difficulty-creating-transform-with-concat-table-and-velocity/95890/9 "2025-01-04T14:44:53Z")

</div>

@GOKUL_ANANTH_M, The trasnform with _“type”: “leftPad”_ did work. I would just like to know if it would be possible to do the left padding directly in velocity. This way the transformation would be smaller and more objective.

---

<div class="post-metadata">

**Author:** ![GOKUL\_ANANTH\_M](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/gokul_ananth_m/32/14416_2.png) [@GOKUL\_ANANTH\_M](https://developer.sailpoint.com/discuss/u/GOKUL_ANANTH_M)\
**Post date:** [January 4, 2025, 3:43pm UTC](https://developer.sailpoint.com/discuss/t/difficulty-creating-transform-with-concat-table-and-velocity/95890/10 "2025-01-04T15:43:33Z")

</div>

Hi @raibom ,

```auto
"value": "#set($desiredLength = 10)#set($paddingChar = '0')#if($employeeNumber > 9999)#set($paddedString = '${paddingChar.substring(0, $desiredLength - 2)}BT')#else#set($paddedString = '${paddingChar.substring(0, $desiredLength - $companyAcronym.length())}$companyAcronym')#end"

```

I think with the help of this, you can get the desired output. I didn’t test this, please inform us if it helps. Thanks!!

---

<div class="post-metadata">

**Author:** ![raibom](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/raibom/32/9517_2.png) [@raibom](https://developer.sailpoint.com/discuss/u/raibom)\
**Post date:** [January 7, 2025, 9:22pm UTC](https://developer.sailpoint.com/discuss/t/difficulty-creating-transform-with-concat-table-and-velocity/95890/11 "2025-01-07T21:22:04Z")

</div>

I preferred to use “type”: “leftPad”, as this code ended up being very large and difficult to understand for future maintenance.

---

<div class="post-metadata">

**Author:** ![raibom](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/raibom/32/9517_2.png) [@raibom](https://developer.sailpoint.com/discuss/u/raibom)\
**Post date:** [January 14, 2025, 8:46pm UTC](https://developer.sailpoint.com/discuss/t/difficulty-creating-transform-with-concat-table-and-velocity/95890/12 "2025-01-14T20:46:41Z")

</div>

@GOKUL_ANANTH_M Is there any way to convert the character to an integer?  
I say this because my transform didn’t work. The variable $employeeNumber comes with the value 010000 and I need to convert it before the condition. I tried $employeeNumber.parseInt() but it gives a template error.

---

<div class="post-metadata">

**Author:** ![raibom](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/raibom/32/9517_2.png) [@raibom](https://developer.sailpoint.com/discuss/u/raibom)\
**Post date:** [January 14, 2025, 9:28pm UTC](https://developer.sailpoint.com/discuss/t/difficulty-creating-transform-with-concat-table-and-velocity/95890/13 "2025-01-14T21:28:51Z")

</div>

It worked with

```auto
"value": "#set($chapaInt = 0)#if($chapaInt.parseInt($chapa)>9999)BI#{else}$siglaEmpresa#end"

```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sailpoint/original/2X/f/f2136700ed5e3703e0b85e02f6be799dacca7735.png) [@system](https://developer.sailpoint.com/discuss/u/system)\
**Post date:** [March 15, 2025, 9:29pm UTC](https://developer.sailpoint.com/discuss/t/difficulty-creating-transform-with-concat-table-and-velocity/95890/14 "2025-03-15T21:29:27Z")

</div>

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