# Collection runner - Skip a request when CSV value is blank

**URL:** <https://community.postman.com/t/collection-runner-skip-a-request-when-csv-value-is-blank/30869>\
**Category:** Help Hub\
**Tags:** tests, variables, collections\
**Created:** [December 20, 2021, 3:36pm UTC](https://community.postman.com/t/collection-runner-skip-a-request-when-csv-value-is-blank/30869 "2021-12-20T15:36:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniel.sessions](https://avatars.discourse-cdn.com/v4/letter/d/47e85d/32.png) [@daniel.sessions](https://community.postman.com/u/daniel.sessions)\
**Post date:** [December 20, 2021, 3:36pm UTC](https://community.postman.com/t/collection-runner-skip-a-request-when-csv-value-is-blank/30869/1 "2021-12-20T15:36:02Z")

</div>

Hi all - I’m trying to skip a request in a collection when the cell in my CSV is blank but I can’t figure out how to reference this in the pre-request script.

In this example field1, field2 and field3 are individual PUT requests. On the 1st iteration it should skip field3, on the 2nd if should skip field1, on the 3rd it should skip field2 etc.

 ![exampleCSV](https://us1.discourse-cdn.com/getpostman/original/3X/d/5/d54f038ba4c6ec238808e8dd7f41cea014dc2016.jpeg)

Currently a blank cell in the CSV will send blank variable in the PUT request.

Example body:

```auto
{
    "value": "{{field1}}"
}

```

Thanks

---

<div class="post-metadata">

**Author:** ![nrelkov](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/nrelkov/32/10495_2.png) [@nrelkov](https://community.postman.com/u/nrelkov)\
**Post date:** [December 20, 2021, 11:27pm UTC](https://community.postman.com/t/collection-runner-skip-a-request-when-csv-value-is-blank/30869/2 "2021-12-20T23:27:10Z")

</div>

Hi @daniel.sessions

I think your issue may have been answered in another post a little while ago. There are a couple recommendations for solutions in there. The comment that I added at the end may be applicable to your issue as well. Let me know if there are still concerns.

> [@Checking dynamic variables in pre-request script](https://community.postman.com/t/checking-dynamic-variables-in-pre-request-script/30873/4):
>
> Hi @rafall92 If you want to have it determined if you need to run your Request, what I usually end up doing (not sure if there is a better way) is to create a Request that runs before the request that you use. Example: Request 1 (“DataCheck”): No Pre-Request script Have request use Get, if you have an endpoint that is a ping response, use that Tests if(pm.iterationData.get(‘name’) == “”) { postman.setNextRequest(null); } else { postman.setNextRequest(“MyRequest”); } Request 2 (“MyReq…

Hope this helps!

---

<div class="post-metadata">

**Author:** ![daniel.sessions](https://avatars.discourse-cdn.com/v4/letter/d/47e85d/32.png) [@daniel.sessions](https://community.postman.com/u/daniel.sessions)\
**Post date:** [December 29, 2021, 3:57pm UTC](https://community.postman.com/t/collection-runner-skip-a-request-when-csv-value-is-blank/30869/3 "2021-12-29T15:57:40Z")

</div>

Hi @nrelkov

I’m trying to skip the request if the pre-request script detects an empty value in the csv. I’ve checked your post but I’m still unsure on how to apply this. I’ve tried the below to detect an empty cell value and then setNextRequest to skip to the next request but I can’t seem to get it working. Do you have any other ideas?

```auto
if(pm.iterationData.get(field1) == "") {
postman.setNextRequest("request_field2");
}

```

Thanks

---

<div class="post-metadata">

**Author:** ![nrelkov](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/nrelkov/32/10495_2.png) [@nrelkov](https://community.postman.com/u/nrelkov)\
**Post date:** [December 30, 2021, 7:27am UTC](https://community.postman.com/t/collection-runner-skip-a-request-when-csv-value-is-blank/30869/4 "2021-12-30T07:27:09Z")

</div>

Hi @daniel.sessions

So, that code should work but you need to put it into a separate Request.

So, for your case, you have your PUT Request right now that you are trying to use the Pre Request to skip the Request if there is no value. This is not possible as all the Pre Request script is really for is setting up the data to use for the Request. postman.SetNextRequest will do nothing in the Pre Prequest.

This is where a Setup Request can help you. So, for your case, create a new Request (I usually call it something like “Setup”) and put it above your PUT Request in the Collection. Set it up as a GET and point to any endpoint that you have (I usually use a call to a ping API Endpoint if I have one). Dont put anything in the Pre Request or Body of the GET Request, as the details are not important. In the GET Tests, this is where you put that script that you added. This allows you to control whether or not the PUT Request is called or skips to the next one in the Iteration.

Oh, and something to add, you will want to direct the postman.setNextRequest for if there is a value or not, to ensure that you control for when there is a value and when there is not.

For Example:

if(pm.iterationData.get(field1) == “”) {  
postman.setNextRequest(“request\_field2”);  
} else {  
postman.setNextRequest(null); //This ends the current iteration and moves onto the next  
}

//NOTE: you can change the null to any Request you want, I just wanted to show how to end the iteration if needed.

Let me know if you need anything else.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![yashodhal](https://avatars.discourse-cdn.com/v4/letter/y/c89c15/32.png) [@yashodhal](https://community.postman.com/u/yashodhal)\
**Post date:** [February 7, 2022, 5:56pm UTC](https://community.postman.com/t/collection-runner-skip-a-request-when-csv-value-is-blank/30869/5 "2022-02-07T17:56:49Z")

</div>

hello,  
Anyone can tell me how to handle null/empty values in csv file which used for the collection runner.

1. This is my post request body.  

2. This is my test script  

3. This is my csv file  

4. I want to skip this null values and move to next iteration or next filed.(ex:machine\_03 id)  
How can I do it?
