Workflow fix for custom relationship joins #3293
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue: WF does not work when condition is based on custom relationship
Description
Create a custom relationship between two modules. e.g. Create a one-many relationship between Contacts and Opportunities. This should enable a single opportunity to be related to a single contact. A contact can have many opportunities.
Create a WF where the primary module is Contacts. The purpose of the WF is to send a personalised email to the Contact when an opportunity meets a specific condition. For example, The opportunity last modified date is greater than 30 days.
Run the WF and it will fail. The error.log will contain something like
The following was an extract from our sugarcrm.log file prior to the fix
Query Failed: SELECT contacts.id AS id, contacts_opportunities_1.id AS 'contacts_opportunities_1_id' FROM contacts LEFT JOIN contacts_opportunities_1_c ON contacts.id=contacts_opportunities_1_c.contacts_opportunities_1contacts_ida AND contacts_opportunities_1_c.deleted=0
LEFT JOIN opportunities contacts_opportunities_1 ON contacts_opportunities_1.id=contacts_opportunities_1_c.contacts_opportunities_1opportunities_idb AND contacts_opportunities_1.deleted=0
LEFT JOIN opportunities_cstm contacts_opportunities_1_cstm ON opportunities.id = contacts_opportunities_1_cstm.id_c WHERE DATE(contacts_opportunities_1.date_closed) = Curdate() AND contacts_opportunities_1_cstm.service_item_c = '7PTAX' AND contacts_opportunities_1_cstm.job_sortable_status_c LIKE CONCAT('%', '7' ,'%') AND contacts.last_name != 'A' AND contacts.deleted = 0 : MySQL error 1054: Unknown column 'opportunities.id' in 'on clause'
Motivation and Context
This change fixes a bug in the code by adding a check to see if the relationship is a custom one or not.
How To Test This
As described
Types of changes
Final checklist