Comparing Two strings in Transform

Hi Experts,

Is there any way to check if any particular string exists into another string?
For example
String A=“abcd
String B=“qwertabcdsdfgh”

The method B.contains(A) returns false.

If String A and B are exactly same then only B.contains(A) returns true.

We need solution where comparing String A and B should return true as String A exists into String B.

Regards,
Bhushan Dhodi

Hi @bhushan008,

try to use it:

import org.apache.commons.lang3.StringUtils;
StringUtils.containsIgnoreCase(B, A);

Also, exist String.matches() function but it works with regex.

Hi @enistri_devo ,

We need to compare two strings in transform.
Will it work in transform as well?
Any documentation do we have on available methods?

Regards,
Bhushan Dhodi

Those are java instructions on string, you can find it on oracle for example

https://docs.oracle.com/javase/8/docs/api/java/lang/String.html

https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html

1 Like

Hi @bhushan008 ,
Static transform might support it, as it uses velocity template.

Hi @bhushan008 look at these transforms

Index Of | SailPoint Developer Community
Static | SailPoint Developer Community

This will do what you are looking to achieve. Just change the values accordingly

{
  "name": "Transform",
  "type": "static",
  "attributes": {
    "value": "#if ($function.contains('*value*'))true#{else}false#end",
    "function": {
      "type": "firstValid",
      "attributes": {
        "values": [
          {
            "type": "accountAttribute",
            "attributes": {
              "attributeName": "*attributeName*",
              "sourceName": "*sourceName*"
            }
          },
          "xxx"
        ]
      }
    }
  }
}

Phil

2 Likes

@bhushan008 You can also try something like this:

{
    "name": "Compare String TRN",
    "type": "static",
    "attributes": {
        "FristString": {
            "attributes": {
                "values": [
                    {
                        "attributes": {
                            "sourceName": "Test Source",
                            "attributeName": "FristAttribute"
                        },
                        "type": "accountAttribute"
                    },
                    "None"
                ]
            },
            "type": "firstValid"
        },
        "SecondString": {
            "attributes": {
                "values": [
                    {
                        "attributes": {
                            "sourceName": "Test Source",
                            "attributeName": "SecondAttribute"
                        },
                        "type": "accountAttribute"
                    },
                    "None"
                ]
            },
            "type": "firstValid"
        },
        "value": "#if($SecondString != 'None' && $FristString != 'None' && $SecondString.contains($FristString))True#{else}False#end#"
    },
    "internal": false
}
2 Likes

you can’t import libraries in a transform :frowning:

1 Like

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