doesn't have to be a restlet, but you need to use some server side script. you could (hypothetically) use a user event or scheduled script if it made more sense.
N/task
tasks are inherently asynchronous, so it doesn't make a lot of sense for them to be in the 'synchronous' client-side script