and more in a single search tool across platforms. Read the announcement here. |
03/25/2024 09:05 PM
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.
{
"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
]
}
}
]
}
03/25/2024 09:26 PM
It works for us
03/26/2024 03:21 PM - edited 03/26/2024 03:21 PM
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>",
03/26/2024 07:42 PM
You can change based on your requirement