# Set Environment inside Visualizer Template

**URL:** <https://community.postman.com/t/set-environment-inside-visualizer-template/9133>\
**Category:** Help Hub\
**Tags:** environments, visualizer\
**Created:** [November 20, 2019, 2:51pm UTC](https://community.postman.com/t/set-environment-inside-visualizer-template/9133 "2019-11-20T14:51:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sebaestschjin](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@Sebaestschjin](https://community.postman.com/u/Sebaestschjin)\
**Post date:** [November 20, 2019, 2:51pm UTC](https://community.postman.com/t/set-environment-inside-visualizer-template/9133/1 "2019-11-20T14:51:01Z")

</div>

Hi,

is it possible to manipulate the postman environment inside the script of the visualizer? I tried to use pm.environment.set() as I would on the regular test script. But that doesn’t seem to do anything.

What I’m trying to do is to use the visualizer to show a simple table of the response data. Every data point has a name and an ID. When clicking on a row of the table, the ID of the data point should be added to the postman environment, so that it can be used in other requests that require that ID. For now we always use the first entry as the ID, so it would be cool to have that kind of simple selection mechanism. 🙂

This is my example visualizer so far:

```
const template = `<table id="tableId" class="tftable" border="1">
    <tr>
        <th>Name</th>
        <th>ID</th>
    </tr>
    
    {{#each response.values}}
    {{#each value}}
    <tr id="{{id}}"">
        <td id={{@key}}>{{name}}</td>
        <td>{{id}}</td>
    </tr>        
    {{/each}}{{/each}}
</table>    

<script>
    function addRowHandlers() {
        var table = document.getElementById("tableId");
        var rows = table.getElementsByTagName("tr");
        
        for (i = 0; i < rows.length; i++) {
            var currentRow = table.rows[i];
            var createClickHandler = 
                function(row) {
                    return function() { 
                        var cell = row.getElementsByTagName("td")[0];
                        var id = cell.innerHTML;
                        alert(id);
                        pm.environment.set("FOOBAR", id);
                    };
                };
            currentRow.onclick = createClickHandler(currentRow);
        }
    }
    
    window.onload = addRowHandlers();
</script>`

pm.visualizer.set(template, {
    response: pm.response.json()
});

```

---

<div class="post-metadata">

**Author:** ![arlem](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/arlem/32/3078_2.png) [@arlem](https://community.postman.com/u/arlem)\
**Post date:** [November 21, 2019, 6:32am UTC](https://community.postman.com/t/set-environment-inside-visualizer-template/9133/2 "2019-11-21T06:32:57Z")

</div>

Hi @Sebaestschjin and welcome here 😃

What you’re asking isn’t feasible at the moment. Someone already opened a feature request along these lines, you may want to give it a +1!

> <https://github.com/postmanlabs/postman-app-support/issues/7610>
>
> Using the Visualisations, it's possible create interactions as well while displa…ying the response data.
> It would be a great addition if these interactions would allow a developer to generate actions that execute requests from the same collection thereby also being able to fill the parameters of such a request with data from the current repsonse. This would allow for a complete interactive way of browsing through the API.
> 
> For example:
> \* A call is done to retrieve an overview of users (/api/users/)
> \* You would click on the id of a user and this would trigger the call that retrieves information about this user (/api/user/{id})
> \* Among that information is an overview of services that this user has signed up for. Clicking on the id of a service would then trigger the call with more information about that server (/api/service/{id})
> etc.
> 
> I know it's currently possible to set variables based on the repsonse of a call and use those values in subsequent calls, but this doesn't work when there's multiple values to choose from (as is the case in my example)
> 
> With this addition you would be able to set up an interactive way of browsing through the data of your whole api, all from within Postman.
