Dynamics Mobile Docs
Ask or search…

BackendService - schedule example

Run server-side code on a predefined time interval
The following example illustrates how to run server-side code on a predefined interval.
import { ApplicationBackendServiceBase, BackendServiceEventTypes } from '@dms';
import { MyEvent } from '@dms-bo';
export * from '@dms';
export * from '@dms-bo';
export default class BackendService extends ApplicationBackendServiceBase {
public async processEvent(
event: { eventName: string;
eventArguments: {
appArea: string;
appCode: string;
userName: string;
request: {
httpMethod: string;
restCommand: string;
headers: any;
body: any;
queryStringParameters: any;
}): Promise<any> {
switch (event.eventName) {
case "system:schedule:tick": {
//create a new record in the database on every call
const myEvent = new MyEvent();
myEvent.onDateAndTime = moment(new Date()).toDate();
await myEvent.add();
default: return;
The given code will be only called on each system tick , which will make your code to run regularly.
Dynamics Mobile provided by Mobile Affairs Ltd. | 1712 Sofia, Bulgaria, Alexander Malinov 51 | [email protected]