# Extract IDs of items in the DataGrid - selectedRows variable

**URL:** <https://community.weweb.io/t/extract-ids-of-items-in-the-datagrid-selectedrows-variable/3128>\
**Category:** Ask us anything\
**Created:** [June 20, 2023, 4:51am UTC](https://community.weweb.io/t/extract-ids-of-items-in-the-datagrid-selectedrows-variable/3128 "2023-06-20T04:51:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dorian](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/dorian/32/13183_2.png) [@Dorian](https://community.weweb.io/u/Dorian)\
**Post date:** [June 20, 2023, 4:51am UTC](https://community.weweb.io/t/extract-ids-of-items-in-the-datagrid-selectedrows-variable/3128/1 "2023-06-20T04:51:18Z")

</div>

Hi y’all. This should be easy but I can’t figure it out. I simply need a workflow action(s) that extracts the IDs of all the objects in the selectedRows variable and adds them to a new array variable. But everything I try just keeps adding the ID of the first object in the selectedRows variable over and over. Details in loom. Any help appreciated. 🙂

Edit: I got this to work immediately with Co-Pilot but really want to understand how to do it with nocode please!

> **[Troubleshooting Premiums to Pay Variable 🛠️](https://www.loom.com/share/37f4e4bf2bec498c839e5db017b086e4?sid=425639f7-b1c0-425b-ab45-2c317baad230)**
>
> Hey there! In this Loom, I'm trying to troubleshoot an issue I'm having with the premiums to pay variable. I need to extract the IDs of each selected row in the favorite and add them to this variable so I can submit them to an API. However, I keep...

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [June 20, 2023, 7:07am UTC](https://community.weweb.io/t/extract-ids-of-items-in-the-datagrid-selectedrows-variable/3128/2 "2023-06-20T07:07:13Z")

</div>

I hope this is nocode enough 😃

> **[Understanding Array Indexing in JavaScript 🤔](https://www.loom.com/share/55978a37d0af436daaf8b42156d69fa1)**
>
> Hey there! So, I wanted to explain to you how I solved the problem we were having with array indexing in JavaScript. Basically, I took an array and looped it through another empty array, inserting values at the end. The logic behind this is that we...

---

<div class="post-metadata">

**Author:** ![dorilama](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/dorilama/32/10403_2.png) [@dorilama](https://community.weweb.io/u/dorilama)\
**Post date:** [June 20, 2023, 7:47am UTC](https://community.weweb.io/t/extract-ids-of-items-in-the-datagrid-selectedrows-variable/3128/3 "2023-06-20T07:47:31Z")

</div>

If you need to map over an array, you can just use the map formula.  
For the loop action what you are missing is that the loop itself is an action in weweb and the current value of the iteration is available under the workflow variable tab (it’s easier to find if you give the loop a name)  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/a/a1bce69efa2c5edca798e972af3923e35718f3cb.png)

---

<div class="post-metadata">

**Author:** ![Dorian](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/dorian/32/13183_2.png) [@Dorian](https://community.weweb.io/u/Dorian)\
**Post date:** [June 20, 2023, 11:55pm UTC](https://community.weweb.io/t/extract-ids-of-items-in-the-datagrid-selectedrows-variable/3128/4 "2023-06-20T23:55:40Z")

</div>

map() worked perfectly thanks @dorilama. I imagine I will use that a lot from now on!

---

<div class="post-metadata">

**Author:** ![sasha.carina](https://avatars.discourse-cdn.com/v4/letter/s/ac91a4/32.png) [@sasha.carina](https://community.weweb.io/u/sasha.carina)\
**Post date:** [March 20, 2025, 2:54pm UTC](https://community.weweb.io/t/extract-ids-of-items-in-the-datagrid-selectedrows-variable/3128/5 "2025-03-20T14:54:50Z")

</div>

Hello, I have been stuck on a problem for two days. I think this is the solution however the link no longer works. Could you help me? I have a form that is populated with a variable (it updates when the form loads). The labels are showing up in the dropdown menu but when I submit my form I need the ID’s of the variables returned not the names.
