Hi.
I do not know what happens with my job scheduler. I am apparently configuring my job correctly but it does not work. I tested my function and It works well so it is not the problem (or at least I think so). Please someone who can help me. I will be very greatful.
This is my job:
{
"jobs": [
{
"functionLocation": "/soatEmailNotification.jsw",
"functionName": "sendSoatNotification",
"description": "Send an email notification to customers who SOAT expires 30 days later",
"executionConfig": {
"cronExpression": "0 6 * * *"
}
}
]
}
And this is my function:
import wixData from 'wix-data';
import { sendEmail } from 'backend/sendEmail.jsw';
export function sendSoatNotification() {
let expirationDate = new Date(); // Get today's date.
expirationDate.setDate(expirationDate.getDate() + 30); // Add 30 days to current date.
wixData.query('SOAT')
.find()
.then(results => {
results.items.forEach(item => {
if(item.fechaVencimiento.setHours(0,0,0,0) === expirationDate.setHours(0,0,0,0)){
const emailResult = sendEmail(
item.email, // To email.
item.nombres + ' se vence tu SOAT', // Subject.
'Tu SOAT está próximo a vencer', // Body
'<a href="https://www.protectorseguros.com/soat-sura"><div align="center"><img src="https://static.wixstatic.com/media/9351dc_73f320dfe807421b86cdda49ddbe5fae~mv2.png" width=707 height=1000/></div></a>' // Html.
)
console.log('email sent',item.fechaVencimiento, expirationDate)
}
})
})
}