Announcing the Saviynt Knowledge Exchange unifying the Saviynt forums, documentation, training,
and more in a single search tool across platforms. Read the announcement here.

using regex in connection JSON

darshanmandhane
New Contributor II
New Contributor II

I have a REST connector. I want to add a callcondition with regex in connection json. Is there any sample of the same?

5 REPLIES 5

adarshk
Saviynt Employee
Saviynt Employee

Please share the details on the call condition you are trying to achieve. 

Please find below the action JSON. I have added "No", "NO" & "no" multiple times for checking the values, instead want to check if we can use regex to simplify the condition and combine it in a single check.

{
    "actions": {
        "Disable User": {
            "call": [
                {
                    "name": "call1",
                    "connection": "userAuth",
                    "url": "https://addepar-dev.saviyntcloud.com/ECM/api/v5/updateUser",
                    "httpMethod": "POST",
                    "httpParams": "{\"username\":\"${user.username}\",\"statuskey\":\"0\"}",
                    "httpHeaders": {
                        "Authorization": "${access_token}"
                    },
                    "httpContentType": "application/json",
                    "callCondition": "${(user.customproperty14 == '' || user.customproperty14 == null || user.customproperty14 == \"No\" || user.customproperty14 == \"NO\" || user.customproperty14 == \"no\") && (user.customproperty16 == '' || user.customproperty16 == null)}",
                    "successResponses": {
                        "statusCode": [
                            201,
                            200,
                            204
                        ]
                    }
                }
            ]
        }
    }
}

 

itinjic
New Contributor III
New Contributor III

Here's an example of using a callcondition with regex in connection JSON for a REST connector:

 

```
{
"call": [
{
"name": "call1",
"url": "https://api.example.com",
"httpMethod": "GET",
"callCondition": "${user.username.matches('.*@example\\.com$')}"
},
{
"name": "call2",
"url": "https://api.example.com",
"httpMethod": "POST",
"callCondition": "${user.role == 'admin'}"
}
]
}
```


In this example, call1 will only be executed if the user's username matches the regex pattern `'.*@example\\.com$'`, which means it should end with '@example.com'. Similarly, call2 will only be executed if the user's role is set to 'admin'. You can modify the regex pattern and the condition based on your specific requirements.

How can I make it case insensitive?

itinjic
New Contributor III
New Contributor III

To add a call condition with regex in the connection JSON of a REST connector, you can use the "callCondition" parameter. Here's an example:

```json
{
"call": [
{
"name": "call1",
"connection": "auth",
"url": "https://api.example.com",
"httpMethod": "GET",
"httpHeaders": {
"Authorization": "${access_token}"
},
"callCondition": "${user.username matches '(?i)regex_pattern'}"
}
]
}
```

In the above example, the "callCondition" parameter is used to specify the regex pattern. The `(?i)` at the beginning of the pattern makes it case insensitive. You can replace "regex_pattern" with your desired regex.