# Unable to Add Access inside a loop

**URL:** <https://developer.sailpoint.com/discuss/t/unable-to-add-access-inside-a-loop/81723>\
**Category:** SHF Discussion and Questions\
**Tags:** provisioning, developer-days-2023-idn, workflows, identity-security-cloud\
**Created:** [September 18, 2024, 11:20am UTC](https://developer.sailpoint.com/discuss/t/unable-to-add-access-inside-a-loop/81723 "2024-09-18T11:20:22Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sgupta1](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@Sgupta1](https://developer.sailpoint.com/discuss/u/Sgupta1)\
**Post date:** [September 18, 2024, 11:20am UTC](https://developer.sailpoint.com/discuss/t/unable-to-add-access-inside-a-loop/81723/1 "2024-09-18T11:20:22Z")

</div>

Hi ,  
I am trying to Add Access inside a loop. Same steps I am following without loop it is working fine.  
What I wanted to do is I am getting multiple access items , I am passing it inside a loop and till Get Access it is working fine, as soon as I am adding Manage Access and passing the access item it is getting failed.

Any suggestions would be helpful.

 ![image](https://global.discourse-cdn.com/sailpoint/original/3X/5/9/5962062954e1a552d26e3e778348d6966abd0812.png)

 ![image](https://global.discourse-cdn.com/sailpoint/original/3X/2/d/2de5a59a6e9b6ea4772c49c5e51cb1871ae266f4.png)

FYR this is the input getting passed into loop:

```java
{
  "context": null,
  "context.$": "",
  "input": "ACE Sales Group",
  "start": "Define Variable",
  "steps": {
    "Define Variable": {
      "attributes": {
        "id": "sp:define-variable",
        "variables": [
          {
            "description": "psg2",
            "name": "psg2",
            "transforms": [],
            "variableA.$": "$.loop.loopInput"
          }
        ]
      },
      "displayName": "",
      "nextStep": "Get Access",
      "type": "Mutation"
    },
    "End Step - Success 1": {
      "displayName": "",
      "type": "success"
    },
    "Get Access": {
      "actionId": "sp:access:get",
      "attributes": {
        "accessprofiles": false,
        "entitlements": true,
        "getAccessBy": "searchQuery",
        "query": "name.exact:\"{{$.defineVariable.psg2}}\"",
        "roles": false
      },
      "displayName": "",
      "nextStep": "Manage Access",
      "type": "action",
      "versionNumber": 1
    },
    "Manage Access": {
      "actionId": "sp:access:manage",
      "attributes": {
        "addIdentities.$": "$.getIdentity.id",
        "comments": "Salesforce Access",
        "requestType": "GRANT_ACCESS",
        "requestedItems.$": "$.getAccess.accessItems"
      },
      "displayName": "",
      "nextStep": "End Step - Success 1",
      "type": "action",
      "versionNumber": 1
    }
  },
  "suppliedInlineExpression": {
    "steps": "{\"Define Variable\":{\"attributes\":{\"id\":\"sp:define-variable\",\"variables\":[{\"description\":\"psg2\",\"name\":\"psg2\",\"transforms\":[],\"variableA.$\":\"$.loop.loopInput\"}]},\"displayName\":\"\",\"nextStep\":\"Get Access\",\"type\":\"Mutation\"},\"End Step - Success 1\":{\"displayName\":\"\",\"type\":\"success\"},\"Get Access\":{\"actionId\":\"sp:access:get\",\"attributes\":{\"accessprofiles\":false,\"entitlements\":true,\"getAccessBy\":\"searchQuery\",\"query\":\"name.exact:\\\"{{$.defineVariable.psg2}}\\\"\",\"roles\":false},\"displayName\":\"\",\"nextStep\":\"Manage Access\",\"type\":\"action\",\"versionNumber\":1},\"Manage Access\":{\"actionId\":\"sp:access:manage\",\"attributes\":{\"addIdentities.$\":\"$.getIdentity.id\",\"comments\":\"Salesforce Access\",\"requestType\":\"GRANT_ACCESS\",\"requestedItems.$\":\"$.getAccess.accessItems\"},\"displayName\":\"\",\"nextStep\":\"End Step - Success 1\",\"type\":\"action\",\"versionNumber\":1}}"
  }
}

```

* * *

Thanks

---

<div class="post-metadata">

**Author:** ![shaileeM](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/shaileem/32/15314_2.png) [@shaileeM](https://developer.sailpoint.com/discuss/u/shaileeM)\
**Post date:** [September 18, 2024, 11:57am UTC](https://developer.sailpoint.com/discuss/t/unable-to-add-access-inside-a-loop/81723/2 "2024-09-18T11:57:12Z")

</div>

Hi Sikha,

Can you share your workflow json, masking the necessary.

It will be useful to help your case

Thanks,

---

<div class="post-metadata">

**Author:** ![ipobeidi](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/ipobeidi/32/16000_2.png) [@ipobeidi](https://developer.sailpoint.com/discuss/u/ipobeidi)\
**Post date:** [September 18, 2024, 12:23pm UTC](https://developer.sailpoint.com/discuss/t/unable-to-add-access-inside-a-loop/81723/3 "2024-09-18T12:23:56Z")

</div>

Can you be sure you’re sending a JSONARRAY or List to the Loop?

Best

---

<div class="post-metadata">

**Author:** ![uday\_kilambi](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/uday_kilambi/32/31482_2.png) [@uday\_kilambi](https://developer.sailpoint.com/discuss/u/uday_kilambi)\
**Post date:** [September 18, 2024, 2:13pm UTC](https://developer.sailpoint.com/discuss/t/unable-to-add-access-inside-a-loop/81723/4 "2024-09-18T14:13:48Z")

</div>

Hi @Sgupta1 ,

What is the input provided to the loop? Mostly, the case would the loop input variable used in manage access is not proper.

Please share these details. you can also do a quick verification by adding a send email step in the loop and providing the exact loop variable used in Manage Access step. You can then observe how the value actually translated inside the step.

Regards,  
Uday Kilambi

---

<div class="post-metadata">

**Author:** ![Sgupta1](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@Sgupta1](https://developer.sailpoint.com/discuss/u/Sgupta1)\
**Post date:** [September 18, 2024, 2:16pm UTC](https://developer.sailpoint.com/discuss/t/unable-to-add-access-inside-a-loop/81723/5 "2024-09-18T14:16:13Z")

</div>

We are passing input in the form of JSONARRAY.  
“input”: [  
“ABC”,  
“DEF”  
]

---

<div class="post-metadata">

**Author:** ![Sgupta1](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@Sgupta1](https://developer.sailpoint.com/discuss/u/Sgupta1)\
**Post date:** [September 19, 2024, 2:44pm UTC](https://developer.sailpoint.com/discuss/t/unable-to-add-access-inside-a-loop/81723/6 "2024-09-19T14:44:02Z")

</div>

Hi @uday_kilambi , I tried adding Send Email post get Access step, it seems it is fetching the correct value.

 ![image](https://global.discourse-cdn.com/sailpoint/original/3X/5/3/538a9db75ca24d01f4f0e31687023665a79e8304.png)

---

<div class="post-metadata">

**Author:** ![Yathish](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/yathish/32/11564_2.png) [@Yathish](https://developer.sailpoint.com/discuss/u/Yathish)\
**Post date:** [September 19, 2024, 2:51pm UTC](https://developer.sailpoint.com/discuss/t/unable-to-add-access-inside-a-loop/81723/7 "2024-09-19T14:51:26Z")

</div>

There might be parsing issue with Manage access. Replace Manage access with HTTP operation, This worked for me.  
Reference : [IDN Workflow remove access request](https://developer.sailpoint.com/discuss/t/idn-workflow-remove-access-request/5179)

---

<div class="post-metadata">

**Author:** ![Sgupta1](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@Sgupta1](https://developer.sailpoint.com/discuss/u/Sgupta1)\
**Post date:** [October 15, 2024, 12:31pm UTC](https://developer.sailpoint.com/discuss/t/unable-to-add-access-inside-a-loop/81723/8 "2024-10-15T12:31:20Z")

</div>

Hi All  
We are able to use Add Access and pass it to Manage Access within the loop.  
The execution is getting completed but for one entitlement it is getting failed and for one it is getting passed and entitlement getting assigned.

We are getting the below error:

> {“error”:“task failed: activity error (type: sp:access:manage, scheduledEventID: 23, startedEventID: 24, identity: 1@sp-workflow-worker-stg-us-east-1-7b6d4548f4-vg9rl@): request failed: 400 - 400 Bad Request: (type: HTTP Response Returned a Client Error, retryable: false): request failed: 400 - 400 Bad Request (type: HTTP Response Returned a Client Error, retryable: false): request failed: 400 - 400 Bad Request: (type: HTTP Response Returned a Client Error, retryable: false): request failed: 400 - 400 Bad Request (type: fundamental, retryable: true)”,“workflowId”:"4e2608e0-a00f-4d1b-8f07-4f237af9ad3d-

 ![image](https://global.discourse-cdn.com/sailpoint/original/3X/9/a/9ae01ee5c07b8434b55ec813be2f3654269afbe8.png)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sailpoint/original/2X/f/f2136700ed5e3703e0b85e02f6be799dacca7735.png) [@system](https://developer.sailpoint.com/discuss/u/system)\
**Post date:** [December 14, 2024, 12:32pm UTC](https://developer.sailpoint.com/discuss/t/unable-to-add-access-inside-a-loop/81723/9 "2024-12-14T12:32:09Z")

</div>

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