# How I can put Id of entry in variable by found name?

**URL:** <https://community.postman.com/t/how-i-can-put-id-of-entry-in-variable-by-found-name/38412>\
**Category:** Help Hub\
**Tags:** tests, variables\
**Created:** [August 22, 2022, 12:38pm UTC](https://community.postman.com/t/how-i-can-put-id-of-entry-in-variable-by-found-name/38412 "2022-08-22T12:38:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![avionics-meteorolog6](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@avionics-meteorolog6](https://community.postman.com/u/avionics-meteorolog6)\
**Post date:** [August 22, 2022, 12:38pm UTC](https://community.postman.com/t/how-i-can-put-id-of-entry-in-variable-by-found-name/38412/1 "2022-08-22T12:38:12Z")

</div>

I need to take ID into the variable by found name. Like I have a lot of entries in the response, but I need to find certain name and then take the id of entry.

Body response looks like this  
[  
{  
“ID”: 17,  
“name”: “test”,  
“type”: 1,  
“perUnits”: 3,  
“distanceThresholds”: [  
3  
],  
“measurementThresholds”: [  
3  
],  
“rates”: [  
[  
0  
]  
],  
“size”: 35,  
“breakpoints”: [  
[  
null  
]  
]  
}  
]

I found an entry name by this test:

pm.test(“Take Id by found name”, function () {  
const findML = pm.environment.get(“Variable3”)  
pm.expect(pm.response.text()).to.include(findML);  
return console.log(findML)

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [August 23, 2022, 10:40am UTC](https://community.postman.com/t/how-i-can-put-id-of-entry-in-variable-by-found-name/38412/2 "2022-08-23T10:40:09Z")

</div>

@avionics-meteorolog6

Something along the lines of.

```auto
pm.test("Take Id by found name", () => {
    let search = (response.find(obj => {return obj.name === 'test'}));
    pm.expect(search).to.have.property('id');
    console.log(search.id); // you can store the result in a variable at this point
});

```
