I’m setting up a workflow like the one in the attached image, the custom field of Last Contacted should be updated to the value of the saved notes Date Contacted field if Last Contacted < Date Contacted. However this isn’t working, the workflow never triggers. Digging into the SQL query that the workflow is generating has revealed that SuiteCRM might not be building the query correctly
SELECT notes.id AS id FROM notes LEFT JOIN contacts contact ON notes.contact_id=contact.id AND contact.deleted=0
LEFT JOIN contacts_cstm contact_cstm ON contacts.id = contact_cstm.id_c LEFT JOIN notes_cstm notes_cstm ON notes.id = notes_cstm.id_c
WHERE contact_cstm.last_contacted_c < notes_cstm.date_contacted_c AND notes.id = 'a5a2e1b4-bbdf-86d4-88c4-594ac9f763bd'
is the output from SuiteCRM, when executed against MySQL as a standalone query it fails on line 2 with the error Unknown Column 'contacts.id in ‘on clause’, this appears to be caused by the use of an alias for the contacts table in the first left join then not using the alias in the second left join
If the query is modified to
SELECT notes.id AS id FROM notes LEFT JOIN contacts contact ON notes.contact_id=contact.id AND contact.deleted=0
LEFT JOIN contacts_cstm contact_cstm ON contact.id= contact_cstm.id_c LEFT JOIN notes_cstm notes_cstm ON notes.id = notes_cstm.id_c
WHERE contact_cstm.last_contacted_c < notes_cstm.date_contacted_c AND notes.id = 'a5a2e1b4-bbdf-86d4-88c4-594ac9f763bd'
It executes successfully.
Any thoughts on this, did I build my workflow wrong or do I need to submit a bug report on GitHub?