Unable to loop through all Global variable

Hello All,

I am very new to postman and apologies for asking this naive question : I need to loop through global variables and pass them as parameters. I tried to use this block of example from postman itself but every time only first value is being passed after that there is no execution.

This is the block of code :-


var counter = pm.variables.get('counter');

if(pm.globals.has("subscriptionID" + counter)){
    var custSubID = pm.globals.get("subscriptionID" + counter)


My scenario is explained below :-

I am using a RestAPI for getting list of my cloud subscriptions. After getting my subscriptionID, I am passing it to another subscription to retrieve list of tickets created in them. Under Global variables, I do see that all subscriptions are shown as mentioned below :

subscriptionID0 : dxxxx-xxxxxx-xxxxxxxx-xxxxxxxxxxxxxx
subscriptionID1 : exxxx-xxxxxx-xxxxxxxx-xxxxxxxxxxxxxx
subscriptionID2 : fxxxx-xxxxxx-xxxxxxxx-xxxxxxxxxxxxxx

I would appreciate any guidance on the same.