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

coupa RemoveAccessJSON

iam01
Regular Contributor
Regular Contributor

hi Team,

 

Could you please confirm that the OOTB coupa RemoveAccessJSON works without any modifications? The reason why I am asking is that the logic for Role does not appear correct to me. Thanks in advance.

 

https://docs.saviyntcloud.com/bundle/Coupa-v24x/page/Content/Understanding-the-Integration-between-E...

{
  "call": [
    {
      "name": "Role",
      "connection": "acctAuth",
      "url": "https://<BASE_URL>/api/users/${account.accountID}",
      "httpMethod": "GET",
      "httpParams": "",
      "httpHeaders": {
        "X-COUPA-API-KEY": "${access_token}",
        "Accept": "application/json"      },
      "httpContentType": "application/json"    },
    {
      "name": "Role",
      "connection": "acctAuth",
      "url": "https://<BASE_URL>/api/users/${account.accountID}",
      "httpMethod": "PUT",
      "httpParams": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><user><roles></roles></user>",
      "httpHeaders": {
        "X-COUPA-API-KEY": "${access_token}",
        "Accept": "application/xml"      },
      "httpContentType": "application/xml"    },
    {
      "name": "Role",
      "connection": "acctAuth",
      "url": "https://<BASE_URL>/api/users/${account.accountID}",
      "httpMethod": "PUT",
      "httpParams": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><user><roles>${String rolesStr = '';int size = response.Role1.message.roles?.size();int i = 0;for (Map map : response.Role1.message.roles){if(!map.name.equals(entitlementValue.entitlement_value)){rolesStr=rolesStr+'<role><name>'+map.name+'</name></role>';i++;if(i == size){return rolesStr;}}else{i++;if(i == size){return rolesStr;}}}}</roles></user>",
      "httpHeaders": {
        "X-COUPA-API-KEY": "${access_token}",
        "Accept": "application/xml"      },
      "httpContentType": "application/xml",
      "successResponses": {
        "statusCode": [
          200,
          201
        ]
      }
    },
    {
      "name": "User Group",
      "connection": "acctAuth",
      "url": "https://<BASE_URL>/api/user_group_memberships?user-id=${account.accountID}",
      "httpMethod": "GET",
      "httpParams": "",
      "httpHeaders": {
        "X-COUPA-API-KEY": "${access_token}",
        "Accept": "application/json"      },
      "httpContentType": "application/json"    },
    {
      "name": "User Group",
      "connection": "acctAuth",
      "url": "https://<BASE_URL>/api/user_group_memberships/${for (Map map : response.get('User Group1').message){if (map.'user-group-id'.toString().equals(entitlementValue.entitlementID)){return map.id;}}}",
      "httpMethod": "DELETE",
      "httpParams": "",
      "httpHeaders": {
        "X-COUPA-API-KEY": "${access_token}",
        "Accept": "application/json"      },
      "httpContentType": "application/json",
      "successResponses": {
        "statusCode": [
          201,
          200
        ]
      }
    },
    {
      "name": "Business Group",
      "connection": "acctAuth",
      "url": "https://<BASE_URL>/api/users/${account.accountID}",
      "httpMethod": "GET",
      "httpParams": "",
      "httpHeaders": {
        "X-COUPA-API-KEY": "${access_token}",
        "Accept": "application/json"      },
      "httpContentType": "application/json"    },
    {
      "name": "Business Group",
      "connection": "acctAuth",
      "url": "https://<BASE_URL>/api/users/${account.accountID}",
      "httpMethod": "PUT",
      "httpParams": "{\"content-groups\":\"\"}",
      "httpHeaders": {
        "X-COUPA-API-KEY": "${access_token}",
        "Accept": "application/json"      },
      "httpContentType": "application/json"    },
    {
      "name": "Business Group",
      "connection": "acctAuth",
      "url": "https://<BASE_URL>/api/users/${account.accountID}",
      "httpMethod": "PUT",
      "httpParams": "${List responseList = response.'Business Group1'.message.'content-groups';if(responseList?.size() == 0){return '{\"content-groups\":\"\"}'}else{Set groupSet = new HashSet();Map test1 = new HashMap();int size = responseList.size();int i = 0;for(Map map: responseList){Map test = new HashMap();i++;if(!map.id.toString().equals(entitlementValue.entitlementID)){test.put('id',map.id);groupSet.add(test);if(i == size){test1.put('content-groups',groupSet);return new com.fasterxml.jackson.databind.ObjectMapper().writeValueAsString(test1)}}else{if(i == size){test1.put('content-groups',groupSet);return new com.fasterxml.jackson.databind.ObjectMapper().writeValueAsString(test1)}}}}}",
      "httpHeaders": {
        "X-COUPA-API-KEY": "${access_token}",
        "Accept": "application/json"      },
      "httpContentType": "application/json",
      "successResponses": {
        "statusCode": [
          200,
          201
        ]
      }
    }
  ]
}

 

3 REPLIES 3

rushikeshvartak
All-Star
All-Star

It works for us


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

iam01
Regular Contributor
Regular Contributor

thanks @rushikeshvartak 

the only reason i asked this question was due to below logic. Not equal? i could not understand the logic. It should be equal to right? please correct me if am wrong. thanks

 

{if(!map.name.equals(entitlementValue.entitlement_value))

 

 {
      "name": "Role",
      "connection": "acctAuth",
      "url": "https://<BASE_URL>/api/users/${account.accountID}",
      "httpMethod": "PUT",
      "httpParams": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><user><roles>${String rolesStr = '';int size = response.Role1.message.roles?.size();int i = 0;for (Map map : response.Role1.message.roles){if(!map.name.equals(entitlementValue.entitlement_value)){rolesStr=rolesStr+'<role><name>'+map.name+'</name></role>';i++;if(i == size){return rolesStr;}}else{i++;if(i == size){return rolesStr;}}}}</roles></user>",

 

You can change based on your requirement 


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