Manage access inside loop workflow

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 :

{
	"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

1 Like