Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflow fix for custom relationship joins #3293

Closed
wants to merge 3 commits into from
Closed

Workflow fix for custom relationship joins #3293

wants to merge 3 commits into from

Conversation

FibreCRM
Copy link

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

  • [ x] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Final checklist

Issue: WF does not work when condition is based on custom relationship
@FibreCRM FibreCRM changed the title Add files via upload Workflow fix for custom relationship joins Mar 18, 2017
This fix address issue #3272
Copy link

@shogunpol shogunpol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace "salesagility:master" branch to "salesagility:hotfix"

@FibreCRM
Copy link
Author

FibreCRM commented Mar 22, 2017

This has been changed now. branched of hotfix rather than master. thanks

@FibreCRM FibreCRM changed the base branch from master to hotfix March 22, 2017 09:36
@david-pili
Copy link
Contributor

david-pili commented Jun 22, 2017

I applied this to my SuiteCRM and it appears to work correctly. Furthermore this bug wasn't just caused by custom relationships, custom fields also caused this and are also fixed by this commit. Having a workflow with Notes as the workflow module with condition comparing a custom field on contacts against a custom notes field would fail.

Edit: I only applied changes from AOW_WorkFlow.php, this pull request has multiple fixes.

@chris001
Copy link
Contributor

@FibreCRM
Travis is not failing this PR when it should: 2 failed unit tests, and the log is showing tons of fatal errors, maybe not related to your PR, maybe some are related.
Nonetheless, those fails are supposed to create a red flag icon, in place of the "green checkbox All checks have passed". The tests have failed.
Can you run the phunit tests on your side? Results?

@cameronblaikie cameronblaikie added the PR:Community Contribution These are contribution made by the community label Dec 3, 2018
@Dillon-Brown
Copy link
Contributor

Closed due to inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR:Community Contribution These are contribution made by the community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants