đź“… How to schedule scenario for first Monday next month (recurring)

Summary

Here’s how to use the Make API module to reschedule the scenario to run only on the first Monday each/next month (instead of running every Monday). Using this method, you can potentially save four operations, and you don’t need an additional filter.

Screenshot_2024-02-06_142424

Just put this somewhere in your scenario (it can even be the trigger module), so it will reschedule itself to the first Monday next month at midnight.

You will need to set up your Make API connection. Instructions can be found in the Help Center. When creating a Make API Token, you need to select the scope “scenarios:write”.

Demo

After running this scenario in February 2024, it has rescheduled to 4th March 2024 (a Monday). When this scenario runs in March, it will reschedule the next run to 1st Apr 2024 (Monday), and so on.

Gimme the module

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

  1. Copy the 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 to paste in the canvas.

  3. Click on each imported module and save it. You will need to set-up/select your Make connection.

Modules JSON Export

{
    "subflows": [
        {
            "flow": [
                {
                    "id": 2,
                    "module": "make:makeApiCall",
                    "version": 1,
                    "parameters": {
                        "__IMTCONN__": 113550
                    },
                    "mapper": {
                        "url": "/v2/scenarios/{{var.scenario.id}}",
                        "method": "PATCH",
                        "headers": [
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            }
                        ],
                        "body": "{\"scheduling\": \"{ \\\"date\\\": \\\"{{setSecond(setMinute(setHour(addDays(setDay(setDate(addMonths(now; 1); 1); 2); if(formatDate(setDay(setDate(addMonths(now; 1); 1); 2); \"M\") = formatDate(now; \"M\"); 7; 0)); 0); 0); 0)}}\\\", \\\"type\\\": \\\"once\\\" }\"}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 305,
                            "y": 3,
                            "name": "First Monday Next Month"
                        },
                        "restore": {
                            "parameters": {
                                "__IMTCONN__": {
                                    "collapsed": true,
                                    "label": "Make Connection",
                                    "data": {
                                        "scoped": "true",
                                        "connection": "make"
                                    }
                                }
                            },
                            "expect": {
                                "method": {
                                    "mode": "chose",
                                    "label": "PATCH"
                                },
                                "headers": {
                                    "mode": "chose",
                                    "items": [
                                        null
                                    ]
                                },
                                "qs": {
                                    "mode": "chose",
                                    "collapsed": true
                                }
                            }
                        },
                        "parameters": [
                            {
                                "name": "__IMTCONN__",
                                "type": "account:make",
                                "label": "Connection",
                                "required": true
                            }
                        ],
                        "expect": [
                            {
                                "name": "url",
                                "type": "text",
                                "label": "URL",
                                "required": true
                            },
                            {
                                "name": "method",
                                "type": "select",
                                "label": "Method",
                                "required": true,
                                "validate": {
                                    "enum": [
                                        "GET",
                                        "POST",
                                        "PUT",
                                        "PATCH",
                                        "DELETE"
                                    ]
                                }
                            },
                            {
                                "name": "headers",
                                "type": "array",
                                "label": "Headers",
                                "spec": [
                                    {
                                        "name": "key",
                                        "type": "text",
                                        "label": "Key"
                                    },
                                    {
                                        "name": "value",
                                        "type": "text",
                                        "label": "Value"
                                    }
                                ]
                            },
                            {
                                "name": "qs",
                                "type": "array",
                                "label": "Query String",
                                "spec": [
                                    {
                                        "name": "key",
                                        "type": "text",
                                        "label": "Key"
                                    },
                                    {
                                        "name": "value",
                                        "type": "text",
                                        "label": "Value"
                                    }
                                ]
                            },
                            {
                                "name": "body",
                                "type": "any",
                                "label": "Body"
                            }
                        ]
                    }
                }
            ]
        }
    ],
    "metadata": {
        "version": 1
    }
}

See also

samliew – request private consultation

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

4 Likes