# Manage access inside loop workflow

**URL:** <https://developer.sailpoint.com/discuss/t/manage-access-inside-loop-workflow/104142>\
**Category:** SHF Discussion and Questions\
**Tags:** workflows, identity-security-cloud\
**Created:** [March 14, 2025, 3:28pm UTC](https://developer.sailpoint.com/discuss/t/manage-access-inside-loop-workflow/104142 "2025-03-14T15:28:47Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manju22](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@Manju22](https://developer.sailpoint.com/discuss/u/Manju22)\
**Post date:** [March 14, 2025, 3:28pm UTC](https://developer.sailpoint.com/discuss/t/manage-access-inside-loop-workflow/104142/1 "2025-03-14T15:28:47Z")

</div>

Hi,

Case : I need to add entitlement based on the availability of the source on that identity.  
1 . Trigger  
2. Get accounts  
3. Loop and filter at sourceID — $.getAccounts.accounts[?(@.sourceId == “2c9180858066ffd70180851deaac1750”)]  
4.Compare the sourceID  
5. Get access  
6. manage access

But “manage access” is not working inside the loop.

I have attached the JSON.

 ![image](https://global.discourse-cdn.com/sailpoint/original/3X/5/9/5923da6cf0f7e02631027507691df3d1bbe78d11.png)  
[Ravenewworkflow20250314.json](https://developer.sailpoint.com/discuss/uploads/short-url/fFPrkj02DbPaXdMqGKiOoKx4hfW.json) (2.6 KB)

---

<div class="post-metadata">

**Author:** ![JackSparrow](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/jacksparrow/32/19685_2.png) [@JackSparrow](https://developer.sailpoint.com/discuss/u/JackSparrow)\
**Post date:** [March 14, 2025, 4:12pm UTC](https://developer.sailpoint.com/discuss/t/manage-access-inside-loop-workflow/104142/2 "2025-03-14T16:12:08Z")

</div>

Hi @Manju22 ,

What’s the error you are receiving? Not able to grant access using manage access step? Check if Get Access step is actually giving you the output.

---

<div class="post-metadata">

**Author:** ![mpotti](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/mpotti/32/2916_2.png) [@mpotti](https://developer.sailpoint.com/discuss/u/mpotti)\
**Post date:** [March 14, 2025, 4:13pm UTC](https://developer.sailpoint.com/discuss/t/manage-access-inside-loop-workflow/104142/3 "2025-03-14T16:13:54Z")

</div>

Is the entitlement you are trying add requestable?

> **[Actions - SailPoint Identity Services](https://documentation.sailpoint.com/saas/help/workflows/workflow-actions.html#manage-access)**
>
> SailPoint Identity Services Documentation

---

<div class="post-metadata">

**Author:** ![Manju22](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@Manju22](https://developer.sailpoint.com/discuss/u/Manju22)\
**Post date:** [March 17, 2025, 10:04am UTC](https://developer.sailpoint.com/discuss/t/manage-access-inside-loop-workflow/104142/4 "2025-03-17T10:04:37Z")

</div>

Yes, its working without loop.

---

<div class="post-metadata">

**Author:** ![mpotti](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/mpotti/32/2916_2.png) [@mpotti](https://developer.sailpoint.com/discuss/u/mpotti)\
**Post date:** [March 17, 2025, 11:58am UTC](https://developer.sailpoint.com/discuss/t/manage-access-inside-loop-workflow/104142/5 "2025-03-17T11:58:26Z")

</div>

Can you share your loop and each actions config inside the loop? This will help in providing more context so that we can better answer your question.

---

<div class="post-metadata">

**Author:** ![Manju22](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@Manju22](https://developer.sailpoint.com/discuss/u/Manju22)\
**Post date:** [March 17, 2025, 1:36pm UTC](https://developer.sailpoint.com/discuss/t/manage-access-inside-loop-workflow/104142/6 "2025-03-17T13:36:37Z")

</div>

I have found the issue on the loop,I have given wrong ID on the filter and loop is working now. But I get below error on manage access.

“task failed: activity error (type: sp:access:manage, scheduledEventID: 17, startedEventID: 18, identity: 1@sp-workflow-worker-stg-us-east-1-7797b7db98-6nfxk@sp-workflow-engine): 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)”,

[Ravenewworkflow20250317.json](https://developer.sailpoint.com/discuss/uploads/short-url/5D9vq22uXpTStsufVYW1lc2bsz0.json) (2.6 KB)

---

<div class="post-metadata">

**Author:** ![JackSparrow](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/jacksparrow/32/19685_2.png) [@JackSparrow](https://developer.sailpoint.com/discuss/u/JackSparrow)\
**Post date:** [March 17, 2025, 3:35pm UTC](https://developer.sailpoint.com/discuss/t/manage-access-inside-loop-workflow/104142/7 "2025-03-17T15:35:18Z")

</div>

@Manju22 In Manage Access step, below should be `$.trigger.identityId`

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

---

<div class="post-metadata">

**Author:** ![Manju22](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@Manju22](https://developer.sailpoint.com/discuss/u/Manju22)\
**Post date:** [March 18, 2025, 7:07am UTC](https://developer.sailpoint.com/discuss/t/manage-access-inside-loop-workflow/104142/8 "2025-03-18T07:07:01Z")

</div>

No.. I didnt work for “$.trigger.identityId” also. I have verified with both.

---

<div class="post-metadata">

**Author:** ![sidharth\_tarlapally](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/sidharth_tarlapally/32/26178_2.png) [@sidharth\_tarlapally](https://developer.sailpoint.com/discuss/u/sidharth_tarlapally)\
**Post date:** [March 18, 2025, 8:03am UTC](https://developer.sailpoint.com/discuss/t/manage-access-inside-loop-workflow/104142/9 "2025-03-18T08:03:47Z")

</div>

hello @Manju22

**Findings:**  
The workflow loop utilises identityid which is out the loop . In order to use this inside the loop , we have to include them in the loop context .  
The following the update json :

```auto
{
	"name": "Rave new workflow",
	"description": "Rave new workflow",
	"modified": "2025-03-18T07:21:38.756906388Z",
	"modifiedBy": {
		"type": "IDENTITY",
		"id": "2c918087801ecaae01801ee03ec94b0b",
		"name": "Manjuladevi Manickam"
	},
	"definition": {
		"start": "Get Accounts",
		"steps": {
			"End Step — Success": {
				"type": "success"
			},
			"Get Accounts": {
				"actionId": "sp:get-accounts",
				"attributes": {
					"getAccountsBy": "specificIdentity",
					"identity.$": "$.trigger.identityId"
				},
				"displayName": "",
				"nextStep": "Loop",
				"type": "action",
				"versionNumber": 1
			},
			"Loop": {
				"actionId": "sp:loop:iterator",
				"attributes": {
					"context.$": "$.trigger.identityId",
					"input.$": "$.getAccounts.accounts[?(@.sourceId == \"2c9180858066ffd70180851deaac1750\")]",
					"start": "Compare Strings",
					"steps": {
						"Compare Strings": {
							"choiceList": [
								{
									"comparator": "StringEquals",
									"nextStep": "Get Access",
									"variableA.$": "$.loop.loopInput.sourceId",
									"variableB": "2c9180858066ffd70180851deaac1750"
								}
							],
							"defaultStep": "End Step — Success 2",
							"description": null,
							"type": "choice"
						},
						"End Step — Success 1": {
							"type": "success"
						},
						"End Step — Success 2": {
							"type": "success"
						},
						"Get Access": {
							"actionId": "sp:access:get",
							"attributes": {
								"accessprofiles": true,
								"entitlements": true,
								"getAccessBy": "searchQuery",
								"query": "name.exact:\"DanielsAPITesting\" AND source.name:\"Azure Active Directory Members\"",
								"roles": true
							},
							"description": "Get's the DanielsAPITesting entitlement",
							"nextStep": "Manage Access",
							"type": "action",
							"versionNumber": 1
						},
						"Manage Access": {
							"actionId": "sp:access:manage",
							"attributes": {
								"addIdentities.$": "$.loop.context",
								"comments": "Testing",
								"requestType": "GRANT_ACCESS",
								"requestedItems.$": "$.getAccess.accessItems"
							},
							"displayName": "",
							"nextStep": "End Step — Success 1",
							"type": "action",
							"versionNumber": 1
						}
					}
				},
				"description": null,
				"nextStep": "End Step — Success",
				"type": "action",
				"versionNumber": 1
			}
		}
	},
	"creator": {
		"type": "IDENTITY",
		"id": "2c918087801ecaae01801ee03ec94b0b",
		"name": "Manjuladevi Manickam"
	},
	"trigger": {
		"type": "EVENT",
		"attributes": {
			"filter.$": "$[?($.sourceId == \"0847b218f80644d38b8957ba0adb9bde\")]",
			"id": "idn:source-account-created"
		}
	}
}

```

This helps !

Thanks

---

<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:** [May 17, 2025, 8:04am UTC](https://developer.sailpoint.com/discuss/t/manage-access-inside-loop-workflow/104142/10 "2025-05-17T08:04:41Z")

</div>

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