# Defining empty array in collection variables using UI not pm.collectionVariables.set function

**URL:** <https://community.postman.com/t/defining-empty-array-in-collection-variables-using-ui-not-pm-collectionvariables-set-function/15650>\
**Category:** Help Hub\
**Tags:** variables, collections\
**Created:** [September 6, 2020, 5:49pm UTC](https://community.postman.com/t/defining-empty-array-in-collection-variables-using-ui-not-pm-collectionvariables-set-function/15650 "2020-09-06T17:49:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RadwaSaleh](https://avatars.discourse-cdn.com/v4/letter/r/b9bd4f/32.png) [@RadwaSaleh](https://community.postman.com/u/RadwaSaleh)\
**Post date:** [September 6, 2020, 5:49pm UTC](https://community.postman.com/t/defining-empty-array-in-collection-variables-using-ui-not-pm-collectionvariables-set-function/15650/1 "2020-09-06T17:49:24Z")

</div>

Hi all,

I want to declare an empty array from UI as collection variable when I set the initial and current value to `[]`. then in the pre-script I push an object as array element it says push is not a function.

when I remove the current value to be blank I receive the same issue.

here is what I want to do with this array

```auto
if(success){
           //do stuff
       }
else{
        //failed_accounts is defined manually in collection variables with current value [] or empty
        let failedAccounts = pm.collectionVariables.get("failed_accounts");
        failedAccounts.push(failed_creds);
        pm.collectionVariables.set("failed_accounts", failedAccounts);
    }

```

---

<div class="post-metadata">

**Author:** ![vdespa](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/vdespa/32/2770_2.png) [@vdespa](https://community.postman.com/u/vdespa)\
**Post date:** [September 8, 2020, 11:59am UTC](https://community.postman.com/t/defining-empty-array-in-collection-variables-using-ui-not-pm-collectionvariables-set-function/15650/2 "2020-09-08T11:59:19Z")

</div>

I don’t think you can define complex data structures, such as arrays, from the UI.

You most likely need to create the array from your scripts.

---

<div class="post-metadata">

**Author:** ![dan.schmidt1](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@dan.schmidt1](https://community.postman.com/u/dan.schmidt1)\
**Post date:** [August 5, 2022, 7:17pm UTC](https://community.postman.com/t/defining-empty-array-in-collection-variables-using-ui-not-pm-collectionvariables-set-function/15650/3 "2022-08-05T19:17:29Z")

</div>

You can enter a variable with a value such as the following in your environment collection (can be done through the GUI  
YOUR\_VARIABLE [“a”, “b”, “c”]

Then in you POST body of your request you can do something like this

“AllowedScopes”: {{YOUR\_VARAIBLE}}

instead of hard coding it like this  
“AllowedScopes”: [  
“a”,  
“b”,  
“c”  
]
