Announcing the SAVIYNT KNOWLEDGE EXCHANGE unifying the Saviynt forums, documentation, training, and more in a single search tool across platforms. Click HERE to read the Announcement.

REST - String Functions

rushikeshvartak
All-Star
All-Star

Can we use string function in ImportAccountEntJSON in colsToProp configuration ? 

 

Requirement :

We have entitlement which name is combination of 2 values from API

- user + readonly

- user + no access 

Can we use string functions such as concat, replace? 

If no then any workaround from saviynt side


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.
15 REPLIES 15

UwarajWaman
New Contributor III
New Contributor III

@rushikeshvartak I am also facing the same requirement where I need to use string functions in colsToProp configuration. Did you find any solution?

sahajranajee
Saviynt Employee
Saviynt Employee

Hello,

You can use the CONST function available and see if you can specify your manipulation there.
Example : 

"responseColsToPropsMap": {
    "name": "#CONST#${String acctId = response.call1.message.responseMessage; acctId = acctId.substring(1, acctId.length()-1); return acctId}~#~char",
    "accounttype": "#CONST#Internal~#~char"
  }

 


Regards,
Sahaj Ranajee
Sr. Product Specialist

UwarajWaman
New Contributor III
New Contributor III

@sahajranajee Thanks for the response. Can this be used in "ImportAccountEntJSON" in "colsToPropsMap" configuration? All the references for CONST function I found are related to provisioning JSONs. 

UwarajWaman
New Contributor III
New Contributor III

@sahajranajee @rushikeshvartak I was able to use the #CONST function successfully in  "ImportAccountEntJSON" in "colsToPropsMap" configuration to concatenate string values from API response.

"customproperty7": "#CONST#${String op = response.operation.operation; String target = response.operation.targetType; ret = op + \" \" + target; return ret}~#~char"

In above example response contains data from "listField".

response.operation.operation is target application JSON mapping ?or same irrespective of application 


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

@rushikeshvartak Following is my API response -

{
    "results": [
        {
            "key": "~565117918",
            "name": "Test Space 1",
            "permissions": [
                {
                    "id": 249135157,
                    "subjects": {
                        "group": {
                            "results": [
                                {
                                    "type": "group",
                                    "name": "site-admins",
                                    "id": "a7f6277b-c40b-4cbf-bcbc-51925e91a7c9"
                                }
                            ]
                        }
                    },
                    "operation": {
                        "operation": "administer",
                        "targetType": "space"
                    }
                },
                {
                    "id": 249135164,
                    "subjects": {
                        "group": {
                            "results": [
                                {
                                    "type": "group",
                                    "name": "site-admins",
                                    "id": "a7f6277b-c40b-4cbf-bcbc-51925e91a7c9"
                                }
                            ]
                        }
                    },
                    "operation": {
                        "operation": "delete",
                        "targetType": "page"
                    }
                }
            ]
        }
    ]
}

And this is how I used the CONST function with string concatenation -

            "SpacePermission": {
                "entTypeOrder": 4,
                "call": {
                    "call1": {
                        "callOrder": 2,
                        "stageNumber": 3,
                        "inputParams": {
                            "entitlementname": "Space"
                        },
                        "http": {
                            "url": "https://#####/api/space?spaceKey=${entitlementID}&expand=permissions",
                            "httpHeaders": {
                                "Authorization": "${access_token}"
                            },
                            "httpContentType": "application/x-www-form-urlencoded",
                            "httpMethod": "GET"
                        },
                        "listField": "results[0].permissions",
                        "keyField": "entitlementID",
                        "colsToPropsMap": {
                            "entitlementID": "id~#~char",
                            "entitlement_value": "#CONST#${String op = response.operation.operation; String target = response.operation.targetType; ret = op + \"-\" + target; return ret}~#~char"
                        }
                    }
                }
            }

it worked 🙂

Concat Logic :

"customproperty7": "#CONST#${String data1 = response.operation.operation; String data2 = response.operation.targetType; ret = data1 + \" \" + data2; return ret}~#~char"

 

Here response. will be hardcoded variable 

operation.operation is path for variable in colsToProps

Note : Don't add listField Path


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

GauravJain
Regular Contributor
Regular Contributor

We can also directly reference the values from Json like this 

"customproperty30": "#CONST#${return response.operation.operation+ \" \" + response.operation.operation}~#~char",

GauravJain
Regular Contributor
Regular Contributor

Question is what if we have dot in attribute name. For example attribute name is "operation.operation" then how do we use it. tried with response.operation~dot#operation but didnt work.

Resolution: To resolve this issue, specify the field name with the separator ~dot#. For example, replace manager.user_name with manager~dot#user_name


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

Hi @rushikeshvartak - i have tried that already and it didn't work , hence posted it on this chain.

Also, are you asking to try "manager~dot#user_name" or "response.manager~dot#user_name". i have tried the later one and it didnt work.

prachi
Regular Contributor II
Regular Contributor II

Can we also use this approach to in the Entitlement_ID & Entitlement_Value field?

I am trying to use the below mapping but instead a entitlement is getting created with the value with CONST

"colsToPropsMap":{
"entitlementID":"#CONST#${String data1 = response.role.id; String data2 = response.product.id; ret = data1 + \"-\" + data2; return ret}~#~char",
"entitlement_value":"#CONST#${String data1 = response.role.name; String data2 = response.product.name; ret = data1 + \"-\" + data2; return ret}~#~char"
}

 

It should work


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

prachi
Regular Contributor II
Regular Contributor II

It is not working.

The API looks like this :

prachi_0-1675746087381.png

In the JSON i have :

"listField":"items",
"keyField":"entitlementID",
"colsToPropsMap":{
"entitlementID":"#CONST#${String data1 = response.role.id; String data2 = response.product.id; ret = data1 + \"-\" + data2; return ret}~#~char",
"entitlement_value":"#CONST#${String data1 = response.role.name; String data2 = response.product.name; ret = data1 + \"-\" + data2; return ret}~#~char"
}

GauravJain
Regular Contributor
Regular Contributor

Hi @prachi 

try using "items.product.id" and "items.role.id" and similary for entitlement_value as well.

it should work.