I thought I would share the working code I ended up using. Hope this can help others. This can be useful for logging any kind of activity and have a shortlist handy.
Parse.Cloud.beforeSave("Task", async function(request, response) {
/* Conditions and other stuff here */
const task = request.object
const historyItem = new Parse.Object('History')
historyItem.set('doneDate', new Date())
historyItem.set('task', task.toPointer())
historyItem.set('owner', task.get('owner'))
await historyItem.save(null, {useMasterKey: true })
task.relation('history').add(historyItem)
//Make sure shortlist contains max 5 items
const array = task.get('recentHistory') || []
array.push(historyItem)
task.set('recentHistory', array.slice(0,5))
})
Please do comment if I made any SNAFUs or misunderstood something important from the comments above.