Using the Send Next Request workflow Consecutively (POSTMAN)

Having issues setting up a second postman.sendNextRequest for automation purposes in POSTMAN. I’m looking to add an additional sendNextRequest workflow that continues to another .sendNextRequest

Context:

I have 3 tests in a POSTMAN Collection (below):

POST Test1
POST Test2
POST JIRA Issue Request #No pre-script requests or tests

Test1 & Test2 both have a enviroment variable called Failures and will calculate the failures in those tests. In Test2, I have a function stating if failures > 0 then postman.sendNextRequest which goes directly to the following POST ‘JIRA Issue Request’. In turn a Issue is created when that request is made. This function is below:

let failures = pm.environment.get("failures");

if (failures === undefined || failures === null){                
    failures = 0;
    pm.environment.set("failures", failures);
}

if (failures > 0) {
    console.log('failures found')
    postman.setNextRequest("JIRA Issue Request")
         //you can reset failures if needed.
    pm.environment.set("failures", 0)       

} else {
    console.log('NO failures')
    postman.setNextRequest(null);

Now, I’d like to add an addition request after after the saying that if failures > 0, then post.sendNextRequest and this time I’d like to send a Slack Message, like so:

POST Test1
POST Test2
POST JIRA Issue Request
POST SLACK Post Message 

I already created and successfully have sent Slack messages from POSTMAN but can’t figure out how to go from JIRA Issue Request (which has no pre-script requests or tests) to another Request, named SLACK Post Message. Which is essentially doing the same thing as JIRA Issue Request, sending a request if there are any errors in Test1 & Test2

I’ve been declaring the ‘Failure’ variable and using the function in the ‘JIRA Issue Request’ in both pre-script request and/or test sections to go to the next request, and it’s not triggering the SLACK Post Message request (not even in the console).

Any help much appreciated.

Answer

I think you don’t need add anything because postman runner will run from head to toe in order naturally.So your wokflow will be:

Test1 --> Test2 --> [check failure] --(yes)--> Jira --> Slack

Test1 --> Test2 --> [check failure] --(no)--> stop