Hi,
Am using SendGrid to send email on form submissions as stated in Velo Tutorial: Sending an Email on Form Submission | Help Center | Wix.com.
This example uses onAfterSave() to trigger sendFormData function so it triggers everytime form is updated and saved.
How can set this send out email only when a specific field, say ‘dueArrivalDate’ is updated and not to send any mail even if all other fields are modified but ‘dueArrivalDate’ remains same?
Any sample code will be of great help
Please guide
Anupam Dubey
Hi Anupam,
The onAfterSave() function is already too late to check since the new value has already replaced the previous value. You can use the onBeforeSave() function to query the database to retrieve the previously saved value of the specific field. You can save this value as a global or in local (wix-storage). Then in the onAfterSave() function, check if the specific field is updated or not. If the value was changed, send the email.
Yisrael
lsn’t there any way using onItemValuesChanged?
Sure - there’s an example in the onItemValuesChanged API docs.