SCHEDULED TASK: Module Development

Miva Knowledge Base
Want to start an online store? We work with you from start to finish, from commerce platform to design to SEO.
Experience counts, and we have a lot.
Important Notice: This information is for internal reference only. Use at your own risk.

SCHEDULED TASK: Module Development

Scot Ranney • February 20, 2026


Adding scheduled tasks to modules is easy once you get the hang of it. The two most important functions are below, self explanitory.

The bit about the system being active l.settings:config:active is specific the mod. There are more scheduled task functions in a module but these two functions are all that you usually need to deal with.

<MvFUNCTION NAME = "ScheduledTaskModule_Operations" PARAMETERS = "module var, operations var" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.settings" VALUE = "{ config(l.module_settings) }" />
	
	<MvIF EXPR = "{ l.settings:config:active NE 1 }">
		<MvFUNCRETURN VALUE = "{ 1 }">
	</MvIF>

	<MvASSIGN NAME = "l.info:code" VALUE = "customerstatus" />
	<MvASSIGN NAME = "l.info:descrip" VALUE = "Remove Unverified Customers" />
	<MvASSIGN NAME = "l.ok" VALUE = "{ miva_array_insert(l.operations,l.info,-1) }" />
	
	<MvASSIGN NAME = "l.info:code" VALUE = "process_expiration" />
	<MvASSIGN NAME = "l.info:descrip" VALUE = "Process Expired Accounts" />
	<MvASSIGN NAME = "l.ok" VALUE = "{ miva_array_insert(l.operations,l.info,-1) }" />

	<MvFUNCTIONRETURN VALUE = "{ miva_array_elements(l.operations) }">
</MvFUNCTION>

<MvFUNCTION NAME = "ScheduledTaskModule_Execute" PARAMETERS = "module var, task var" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.settings" VALUE = "{ config(l.module_settings) }" />

	<MvIF EXPR = "{ l.settings:config:active NE 1 }">
		<MvFUNCRETURN VALUE = "{ 1 }">
	</MvIF>
	<MvIF EXPR = "{ l.task:operation EQ 'customerstatus' }">
		<MvASSIGN NAME = "l.ok" VALUE = "{ tracking_cleanup(l.null,l.settings) }" />
	</MvIF>
	<MvIF EXPR = "{ l.task:operation EQ 'process_expiration' }">
		<MvASSIGN NAME = "l.ok" VALUE = "{ process_expiration(l.settings) }" />
	</MvIF>
				
	<MvFUNCRETURN VALUE = "{ 1 }">
</MvFUNCTION>

Creating a scheduled task in the store for this module is as simple as going to:

Store Settings > Scheduled Tasks > Create New Scheduled Task

Give it a description and then choose from the dropdown the task. The task name begins with the module and then shows the "operation" name above.

Ignore everything related to Trigger and otherwise decide how often you want the task to run and then save.


https://www.scotsscripts.com/mvblog/scheduled-task-module-development.html

mvkb_module mvbk_scheduled_task