# Unable to loop through multiple values in workflow

**URL:** <https://developer.sailpoint.com/discuss/t/unable-to-loop-through-multiple-values-in-workflow/87285>\
**Category:** SHF Discussion and Questions\
**Tags:** workflows, identity-security-cloud\
**Created:** [October 29, 2024, 12:55pm UTC](https://developer.sailpoint.com/discuss/t/unable-to-loop-through-multiple-values-in-workflow/87285 "2024-10-29T12:55:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![yatharth\_dutt](https://avatars.discourse-cdn.com/v4/letter/y/a8b319/32.png) [@yatharth\_dutt](https://developer.sailpoint.com/discuss/u/yatharth_dutt)\
**Post date:** [October 29, 2024, 12:55pm UTC](https://developer.sailpoint.com/discuss/t/unable-to-loop-through-multiple-values-in-workflow/87285/1 "2024-10-29T12:55:05Z")

</div>

Hi,

I am trying to create a workflow where if an access profile is approved, the workflow triggers and checks the request decision. The workflow then checks if the access profile contains the entitlements from a specific OU, while doing this i also pull the list of entitlements in that Access profile with HTTP action(by calling search api).  
I am trying to run a loop over each entitlement and do an API call using HTTP action with the value of entitlement in its body.

While trying to do this, I am getting errorMessage : “unexpected end of JSON input”,

Could you please share what I may be doing wrong here?

 ![shadowgroupsnotification20241029](https://global.discourse-cdn.com/sailpoint/original/3X/c/d/cd0f312efbbd6918af8273be8d2e699b38ec04ed.png)

---

<div class="post-metadata">

**Author:** ![Santhakumar](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/santhakumar/32/17329_2.png) [@Santhakumar](https://developer.sailpoint.com/discuss/u/Santhakumar)\
**Post date:** [October 29, 2024, 12:56pm UTC](https://developer.sailpoint.com/discuss/t/unable-to-loop-through-multiple-values-in-workflow/87285/2 "2024-10-29T12:56:55Z")

</div>

Welcome back @yatharth_dutt

Can you share more info about the error. Like in which steps it failing or the screenshot?

Thanks.

---

<div class="post-metadata">

**Author:** ![yatharth\_dutt](https://avatars.discourse-cdn.com/v4/letter/y/a8b319/32.png) [@yatharth\_dutt](https://developer.sailpoint.com/discuss/u/yatharth_dutt)\
**Post date:** [October 29, 2024, 1:34pm UTC](https://developer.sailpoint.com/discuss/t/unable-to-loop-through-multiple-values-in-workflow/87285/3 "2024-10-29T13:34:49Z")

</div>

This is the loop input

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

I changed the configuration a little and I am not getting any error while doing the http request but the reference variables used in the HTTP action are not able to pull any value. Below is the body of HTTP action  
\</\>  
{  
“sysparm\_id”: " \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* “,  
“sysparm\_quantity”: “1”,  
“variables”: {  
“affected\_ci”: “IdentityNow”,  
“approval”: “requested”,  
“category”: “\*\*\*\*\*\*\*\*\*\*\*\*\*\*”,  
“description”: " \r\n

- User Name: {{$.trigger.requestedFor.name}}

- Date Executed: {{$.defineVariable.time}}

- Object:{{$.loop.loopInput.value}}

- Action taken by: identity now

”,  
“req\_description”: " \r\n

- User Name: {{$.trigger.requestedFor.name}}

- Date Executed: {{$.defineVariable.time}}

- Object: {{$.loop.loopInput.value}}

- Action taken by: identity now

",  
“req\_short\_description”: “User {{$.trigger.requestedFor.name}} Removed to {{$.loop.loopInput.value}}”,  
“request\_state”: “requested”,  
“short\_description”: “User {{$.trigger.requestedFor.name}} Removed to {{$.loop.loopInput.value}}”,  
“state”: “New”,  
“sub\_category”: “IdentityNow Service Request”  
}  
}  
\</\>

---

<div class="post-metadata">

**Author:** ![jesvin90](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/jesvin90/32/5301_2.png) [@jesvin90](https://developer.sailpoint.com/discuss/u/jesvin90)\
**Post date:** [October 29, 2024, 2:47pm UTC](https://developer.sailpoint.com/discuss/t/unable-to-loop-through-multiple-values-in-workflow/87285/4 "2024-10-29T14:47:16Z")

</div>

Hi @yatharth_dutt,

Variables defined outside of a loop cannot be called inside the loop. You will need to define the loopinput and loop context to be called inside the loop.

Try defining a Get Identity Action before your loop and then make it as the loop context, that way you can call the Identity attributes inside the loop like `$.loop.context.name`

Also, you may want to change the object as `Object: {{$.loop.loopInput}}` as your loop input is already the entitlement value.

Take a look at the loop operator documentation for detailed info.

> **[Operators - SailPoint Identity Services](https://documentation.sailpoint.com/saas/help/workflows/workflow-operators.html#loop)**
>
> SailPoint Identity Services Documentation

And the define variable to get the time stamp can also be called inside the loop instead of outside of it.

---

<div class="post-metadata">

**Author:** ![yatharth\_dutt](https://avatars.discourse-cdn.com/v4/letter/y/a8b319/32.png) [@yatharth\_dutt](https://developer.sailpoint.com/discuss/u/yatharth_dutt)\
**Post date:** [October 30, 2024, 6:42am UTC](https://developer.sailpoint.com/discuss/t/unable-to-loop-through-multiple-values-in-workflow/87285/5 "2024-10-30T06:42:16Z")

</div>

Thanks @jesvin90 , Is there a way to get multiple inputs in the context.

---

<div class="post-metadata">

**Author:** ![jesvin90](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/jesvin90/32/5301_2.png) [@jesvin90](https://developer.sailpoint.com/discuss/u/jesvin90)\
**Post date:** [October 30, 2024, 6:55am UTC](https://developer.sailpoint.com/discuss/t/unable-to-loop-through-multiple-values-in-workflow/87285/6 "2024-10-30T06:55:55Z")

</div>

I don’t think WF allows multiple loop contexts. You can have a loop context and a loop input that can be used inside the loop.

---

<div class="post-metadata">

**Author:** ![Santhakumar](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/santhakumar/32/17329_2.png) [@Santhakumar](https://developer.sailpoint.com/discuss/u/Santhakumar)\
**Post date:** [October 30, 2024, 7:02am UTC](https://developer.sailpoint.com/discuss/t/unable-to-loop-through-multiple-values-in-workflow/87285/7 "2024-10-30T07:02:49Z")

</div>

Agree with @jesvin90 As of now there is no way to use multiple loop contexts in the workflow. I have tried this method recently but it not works.

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:** [December 29, 2024, 7:02am UTC](https://developer.sailpoint.com/discuss/t/unable-to-loop-through-multiple-values-in-workflow/87285/8 "2024-12-29T07:02:54Z")

</div>

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