# Getting error "TypeError" when setting a Collection Variable

**URL:** <https://community.postman.com/t/getting-error-typeerror-when-setting-a-collection-variable/52442>\
**Category:** Help Hub\
**Tags:** tests, scripts, datafile\
**Created:** [September 26, 2023, 6:35pm UTC](https://community.postman.com/t/getting-error-typeerror-when-setting-a-collection-variable/52442 "2023-09-26T18:35:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lunar-module-admini7](https://avatars.discourse-cdn.com/v4/letter/l/a88e4f/32.png) [@lunar-module-admini7](https://community.postman.com/u/lunar-module-admini7)\
**Post date:** [September 26, 2023, 6:35pm UTC](https://community.postman.com/t/getting-error-typeerror-when-setting-a-collection-variable/52442/1 "2023-09-26T18:35:55Z")

</div>

Hello, I am getting an error when running my postman tests.

```auto
"TypeError: The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type object".

```

This is my request:

```auto
/v2/verification/transactionrecord/{{transactionRecordId}}/documenturl

```

My pre-requisite script has this code:

```auto
if (pm.iterationData.get("iterationName") == "TC-02 - Status Code is 400 for Non-Cportal application user") {
    pm.collectionVariables.set("transactionRecordId", (pm.iterationData.get("transactionRecordId")));
}

```

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/4/d/4d5e3a6c25594454f2470d955c071ab1f364e8d2.png)

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [September 27, 2023, 12:08pm UTC](https://community.postman.com/t/getting-error-typeerror-when-setting-a-collection-variable/52442/2 "2023-09-27T12:08:35Z")

</div>

Hey @lunar-module-admini7 👋

Welcome to the Postman Community! :postman:

Could you expand on the details and context here, please? Are you able to show your full script and the datafile that you’re using in the Collection Runner?

What is the `transactionRecordId` value here and why are you wrapping that in `()` when setting the variable?

```auto
pm.collectionVariables.set("transactionRecordId", (pm.iterationData.get("transactionRecordId")))

```

---

<div class="post-metadata">

**Author:** ![stephenkeenan](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@stephenkeenan](https://community.postman.com/u/stephenkeenan)\
**Post date:** [October 5, 2023, 2:13pm UTC](https://community.postman.com/t/getting-error-typeerror-when-setting-a-collection-variable/52442/3 "2023-10-05T14:13:05Z")

</div>

Hi @lunar-module-admini7

With the information you’ve provided, there seems to be a loigic error in that your transactionRecordId collection variable will only be set if the iterationName is equal to ‘TC-02 - Status Code…’. So, if iterationName is something else, transactionRecordId will be null.

---

<div class="post-metadata">

**Author:** ![lunar-module-admini7](https://avatars.discourse-cdn.com/v4/letter/l/a88e4f/32.png) [@lunar-module-admini7](https://community.postman.com/u/lunar-module-admini7)\
**Post date:** [October 5, 2023, 4:30pm UTC](https://community.postman.com/t/getting-error-typeerror-when-setting-a-collection-variable/52442/4 "2023-10-05T16:30:35Z")

</div>

Thanks @stephenkeenan the issue is resolved.

---

<div class="post-metadata">

**Author:** ![lunar-module-admini7](https://avatars.discourse-cdn.com/v4/letter/l/a88e4f/32.png) [@lunar-module-admini7](https://community.postman.com/u/lunar-module-admini7)\
**Post date:** [October 5, 2023, 4:31pm UTC](https://community.postman.com/t/getting-error-typeerror-when-setting-a-collection-variable/52442/5 "2023-10-05T16:31:03Z")

</div>

Thank @danny-dainton the issue is resolved.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [October 5, 2023, 4:32pm UTC](https://community.postman.com/t/getting-error-typeerror-when-setting-a-collection-variable/52442/6 "2023-10-05T16:32:03Z")

</div>

Closed on October 5, 2023, 4:32pm UTC


