Router choice by round robin (each scenario run alternate to another branch)

I have in my scenario a router with 3 branches. I want to create a situation in which every time the scenario ran through this router it take one of those 3 branches. Not randomlly but instead like a round rubin order. First run - first branch, the next one to the second branch, the third to the third branch and than the forth - again to the first branch -

Is that feature exist in some way?

Hey @Ido_Puterkovski,

It looks like you can achieve this using the Increment Function before the router module.

I tried to search in Makeโ€™s documentation and found this guide - https://www.make.com/en/help/tools/tools#increment-function

The guide specifically talks about a Round Robin system. Hope this helps. :slight_smile:

~ Jock

2 Likes

To achieve this, your increment module Reset value field should be set to Never, and

You need to use the modulo (mod) operator to divide it by the number of routes you have.

Screenshot_2024-05-07_220507
Screenshot_2024-05-07_220516
Screenshot_2024-05-07_220527 (2)

Module Export

You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.

  1. Copy the JSON code below by clicking the copy button when you mouseover the top-right of the code block
    Screenshot_2024-01-17_200117

  2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the canvas.

  3. Click on each imported module and save it for validation. You may be prompted to remap some variables and connections.

View Module Export Code

JSON

{
    "subflows": [
        {
            "flow": [
                {
                    "id": 1,
                    "module": "util:FunctionIncrement",
                    "version": 1,
                    "parameters": {
                        "reset": "scenario"
                    },
                    "mapper": {},
                    "metadata": {
                        "designer": {
                            "x": -254,
                            "y": 75
                        },
                        "restore": {
                            "parameters": {
                                "reset": {
                                    "label": "Never"
                                }
                            }
                        },
                        "parameters": [
                            {
                                "name": "reset",
                                "type": "select",
                                "label": "Reset a value",
                                "required": true,
                                "validate": {
                                    "enum": [
                                        "run",
                                        "execution",
                                        "scenario"
                                    ]
                                }
                            }
                        ]
                    }
                },
                {
                    "id": 2,
                    "module": "builtin:BasicRouter",
                    "version": 1,
                    "mapper": null,
                    "metadata": {
                        "designer": {
                            "x": -7,
                            "y": 74
                        }
                    },
                    "routes": [
                        {
                            "flow": [
                                {
                                    "id": 3,
                                    "module": "util:SetVariable2",
                                    "version": 1,
                                    "parameters": {},
                                    "filter": {
                                        "name": "first",
                                        "conditions": [
                                            [
                                                {
                                                    "a": "{{1.i % 3}}",
                                                    "o": "number:equal",
                                                    "b": "1"
                                                }
                                            ]
                                        ]
                                    },
                                    "mapper": {
                                        "name": "num",
                                        "scope": "roundtrip",
                                        "value": "{{1.i}}"
                                    },
                                    "metadata": {
                                        "designer": {
                                            "x": 319,
                                            "y": -119
                                        },
                                        "restore": {
                                            "expect": {
                                                "scope": {
                                                    "label": "One cycle"
                                                }
                                            }
                                        },
                                        "expect": [
                                            {
                                                "name": "name",
                                                "type": "text",
                                                "label": "Variable name",
                                                "required": true
                                            },
                                            {
                                                "name": "scope",
                                                "type": "select",
                                                "label": "Variable lifetime",
                                                "required": true,
                                                "validate": {
                                                    "enum": [
                                                        "roundtrip",
                                                        "execution"
                                                    ]
                                                }
                                            },
                                            {
                                                "name": "value",
                                                "type": "any",
                                                "label": "Variable value"
                                            }
                                        ],
                                        "interface": [
                                            {
                                                "name": "num",
                                                "label": "num",
                                                "type": "any"
                                            }
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "flow": [
                                {
                                    "id": 4,
                                    "module": "util:SetVariable2",
                                    "version": 1,
                                    "parameters": {},
                                    "filter": {
                                        "name": "second",
                                        "conditions": [
                                            [
                                                {
                                                    "a": "{{1.i % 3}}",
                                                    "o": "number:equal",
                                                    "b": "2"
                                                }
                                            ]
                                        ]
                                    },
                                    "mapper": {
                                        "name": "num",
                                        "scope": "roundtrip",
                                        "value": "{{1.i}}"
                                    },
                                    "metadata": {
                                        "designer": {
                                            "x": 442,
                                            "y": 76
                                        },
                                        "restore": {
                                            "expect": {
                                                "scope": {
                                                    "label": "One cycle"
                                                }
                                            }
                                        },
                                        "expect": [
                                            {
                                                "name": "name",
                                                "type": "text",
                                                "label": "Variable name",
                                                "required": true
                                            },
                                            {
                                                "name": "scope",
                                                "type": "select",
                                                "label": "Variable lifetime",
                                                "required": true,
                                                "validate": {
                                                    "enum": [
                                                        "roundtrip",
                                                        "execution"
                                                    ]
                                                }
                                            },
                                            {
                                                "name": "value",
                                                "type": "any",
                                                "label": "Variable value"
                                            }
                                        ],
                                        "interface": [
                                            {
                                                "name": "num",
                                                "label": "num",
                                                "type": "any"
                                            }
                                        ]
                                    }
                                }
                            ]
                        },
                        {
                            "flow": [
                                {
                                    "id": 5,
                                    "module": "util:SetVariable2",
                                    "version": 1,
                                    "parameters": {},
                                    "filter": {
                                        "name": "third",
                                        "conditions": [
                                            [
                                                {
                                                    "a": "{{1.i % 3}}",
                                                    "o": "number:equal",
                                                    "b": "0"
                                                }
                                            ]
                                        ]
                                    },
                                    "mapper": {
                                        "name": "num",
                                        "scope": "roundtrip",
                                        "value": "{{1.i}}"
                                    },
                                    "metadata": {
                                        "designer": {
                                            "x": 318,
                                            "y": 244
                                        },
                                        "restore": {
                                            "expect": {
                                                "scope": {
                                                    "label": "One cycle"
                                                }
                                            }
                                        },
                                        "expect": [
                                            {
                                                "name": "name",
                                                "type": "text",
                                                "label": "Variable name",
                                                "required": true
                                            },
                                            {
                                                "name": "scope",
                                                "type": "select",
                                                "label": "Variable lifetime",
                                                "required": true,
                                                "validate": {
                                                    "enum": [
                                                        "roundtrip",
                                                        "execution"
                                                    ]
                                                }
                                            },
                                            {
                                                "name": "value",
                                                "type": "any",
                                                "label": "Variable value"
                                            }
                                        ],
                                        "interface": [
                                            {
                                                "name": "num",
                                                "label": "num",
                                                "type": "any"
                                            }
                                        ]
                                    }
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ],
    "metadata": {
        "version": 1
    }
}

samliew โ€“ request private consultation

Join the unofficial Make Discord server to chat with other makers!

3 Likes

Thanks @Jock_Learns ! thas sounds good

@samliew - you are always bring the best and simpliest solutions.
Thanks a lot.

I have just two quastion regard your amazing explanation:

  1. Could you explain to me what is the reaso that you wrote in the equal to area - 0/1/2? (and not 1/2/3)?

  2. Just to make sure - I donโ€™t need the set variable modules as part of the scenario. that was just a sample of continuing the run after the scenario run one of the branches.
    Am I right?

I understand that I am only need the filters with the various values (3 for example for 3 REPs) and the rest of the scenario can be real actions in monday or other apps.

Am I right?

2 Likes

Modulo is basically the remainder from division.

First time scenario runs, the value of i is 1.

1 / 3 = 0 remainder 1
2 / 3 = 0 remainder 2
3 / 3 = 1 remainder 0
4 / 3 = 1 remainder 1
5 / 3 = 1 remainder 2
6 / 3 = 2 remainder 0

Yes, need modules there for the example filters to work.

2 Likes

So if I will have 4 rep I should fill - 0/1/2/3 (each for different route)?

or 1/2/3/0, if you want the first route to run first.

2 Likes

Thanks bro. if there is any way I can provide more compliments about you for whom you want - I will be happy to help because you are really Maestro!

4 Likes