đź“… How to schedule scenario for the last day next month (recurring)

Summary

Here’s how to use the Make API module to reschedule the scenario to run only on the last day next month. Using this method, you can potentially save three operations (since you do not need to run on all 28/29/30/31), and you don’t need an additional filter.

Screenshot_2024-02-06_152831

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

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 31st March 2024. When this scenario runs in March, it will reschedule the next run to 30th Apr 2024, 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": 3,
                    "module": "make:makeApiCall",
                    "version": 1,
                    "parameters": {
                        "__IMTCONN__": 113550
                    },
                    "mapper": {
                        "url": "/v2/scenarios/{{var.scenario.id}}",
                        "body": "{\"scheduling\": \"{ \\\"date\\\": \\\"{{setSecond(setMinute(setHour(setDate(addMonths(now; 2); 0); 12); 0); 0)}}\\\", \\\"type\\\": \\\"once\\\" }\"}",
                        "method": "PATCH",
                        "headers": [
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            }
                        ]
                    },
                    "metadata": {
                        "designer": {
                            "x": -30,
                            "y": -342,
                            "name": "Last Day Next Month"
                        },
                        "restore": {
                            "expect": {
                                "qs": {
                                    "mode": "chose",
                                    "collapsed": true
                                },
                                "method": {
                                    "mode": "chose",
                                    "label": "PATCH"
                                },
                                "headers": {
                                    "mode": "chose",
                                    "items": [
                                        null
                                    ]
                                }
                            },
                            "parameters": {
                                "__IMTCONN__": {
                                    "data": {
                                        "scoped": "true",
                                        "connection": "make"
                                    },
                                    "label": "Make Connection",
                                    "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",
                                "spec": [
                                    {
                                        "name": "key",
                                        "type": "text",
                                        "label": "Key"
                                    },
                                    {
                                        "name": "value",
                                        "type": "text",
                                        "label": "Value"
                                    }
                                ],
                                "type": "array",
                                "label": "Headers"
                            },
                            {
                                "name": "qs",
                                "spec": [
                                    {
                                        "name": "key",
                                        "type": "text",
                                        "label": "Key"
                                    },
                                    {
                                        "name": "value",
                                        "type": "text",
                                        "label": "Value"
                                    }
                                ],
                                "type": "array",
                                "label": "Query String"
                            },
                            {
                                "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!

7 Likes

Pretty cool, hope yo use it in the future :stuck_out_tongue:

2 Likes

Impressive brother defiantly use in future.

2 Likes

Looking to implement this into a scenario, when I run a test I wanted to confirm the end results. When this Make “Last Day Next Month” module runs… Is it supposed to used the schedule settings within the scenario? Right now the scenario is set to run on March 31st, and when I ran the scenario, the next module didnt update the schedule… I wanted to see what I was missing.

Thanks in advance, this is really cool!

1 Like

Using this scenario as the trigger module (the first module in the scenario), what schedule should I set?

It shouldn’t matter, but I recommend selecting Run Once.

The module will then set the next time it should run.

Hope this helps! Let me know if there are any further questions or issues.

— @samliew


P.S.: Did you know, the concepts of about 70% of questions asked on this forum are already covered in the Make Academy. Investing some effort into it will save you lots of time and frustration using Make later!

1 Like