ISC Transform substring negative end

:bangbang: Please be sure you’ve read the docs and API specs before asking for help. Also, please be sure you’ve searched the forum for your answer before you create a new topic.

Hi Forum,

I do have problem in settings up transform in attribute “distinguishName”. I want to subtract 18 characters on the distinguishName value and I want to get the end value.

if the value is India, the transform will return “india” value.
if the value is not India, the transform will return “USA” value.

I have tried this transform on my end. Maybe there’s something wrong in my code that returns Failed value on my custom attribute added on my Identity Profile.

{
    "name": "Test - Location Identifier DN",
    "type": "static",
    "attributes": {
        "trimmedValue": {
            "type": "substring",
            "attributes": {
                "input": {
                    "type": "accountAttribute",
                    "attributes": {
                        "attributeName": "distinguishedName",
                        "sourceName": "Active Directory"
                    }
                },
                "begin": 0,
                "end": -18
            }
        },
        "value": "#if($trimmedValue.toLowerCase().endsWith('india'))India#else#USA#end"
    },
    "internal": false
}

@testipona Can you please share the sample DN? and are you sure that these values will always come after 18 chars only?

hi @shekhardas1825 yup, all of our accounts ended in 18 characters before the ‘india’ value.

here’s the dn value sample:

CN=John Doe,OU=Finance,OU=Production,OU=User,DC=India,DC=spdev,DC=local

Hi @testipona ,
For your requirement, instead of calculating substrings, just check like if the DN contains the string “DC=India”, then display India, else display USA

@testipona you can simplify it as mentionned previously :

{
  "name": "Test - Location Identifier DN",
  "type": "static",
  "attributes": {
    "dnValue": {
      "type": "accountAttribute",
      "attributes": {
        "attributeName": "distinguishedName",
        "sourceName": "Active Directory"
      }
    },
    "value": "#if($dnValue && $dnValue.toLowerCase().contains('dc=india'))India#else#USA#end"
  },
  "internal": false
}

@testipona you cannot use substring here in this condition as the position of the string is not same every time for e.g. name will definitely different. It’s not a static DN.

You can use the contains operation try using the transform shared by @baoussounda .

Regards,

Shekhar Das

Hi @testipona

Many ways to do it including the ones mentioned above.

Also, Replace transform Replace | SailPoint Developer Community

  • Use something like “.*DC=India,DC=spdev,DC=local” as your regex match

and Get End Of String transform Get End of String | SailPoint Developer Community

  • Use 26 characters and you will get “DC=India,DC=spdev,DC=local”

Thanks @baoussounda thanks for letting me know. Yeah instead of trimming, we’ll just use contains for the validation :slight_smile: