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
Email Addresses Automatically Deleted By Workflows Relating to Contacts #7842
Comments
Hi @deuks, Would you be able to provide screenshots of the workflow that you were using to replicate this issue? |
This should not be closed because it is not solved. I have the same issue, only difference is I am using MassUpdate. I opened one oldddd CRM 7.8.8 and did not have this issue. |
This issue is much bigger than I previously thought. Now I have realized that Inline editing on any field on the contact module will also delete email addresses down to 2 email addresses! Why are there literally zero attempts to address this? This was tested on a fresh install of 7.10.29. This was also tested on the SuiteCRM demo and the same issue was prevelant, This is massive data loss and frankly makes inline editing useless if it will cause fields to unrelate/delete. There obviously needs to be major time invested into making sure this bug isn't in other areas of the system. I would assume leads has similar issues, and perhaps even accounts. |
Just tested on a clean install of 7.10.29 and 7.11.18.. The issue is the same on accounts ! |
For some reason, on the |
I was able to fix it by changing
if (!empty($current_links) && $isConversion) { |
@deuks @JanSiero @fcorluka @pribeiro42 After analysing the problem the issue seem to have been caused by the code mentioned on this comment: #5203 (comment) It was re-inializing the list of email addresses just adding Created MR to fix revert code and fix this issue |
- Revert 41ee520 - Fixes issue in workflows, where email addresses where being removed. -- this happened if record had more than 2 email addresses
If a workflow runs and makes changes to a contact, if the contact has more than 2 emails, all but 2 emails are deleted
There are some issues (specifically issue #6983, although I don't know if the cause is related) that are similar, but nothing that specifically relates to workflow. This has been tested on demo.
Issue
When a workflow is created, and modifies a contact record, if the contact has more than 2 emails, all but 2 emails are deleted. This is not related to only one type of workflow and is reproducible on save, on scheduler, on all, and doesn't matter which module the workflow is related to, as long as the workflow ends up modifying some field on contact.
I have pictures detailing the contact before and after.
Expected Behavior
Workflow doesn't delete email addresses by itself
Actual Behavior
What is occurring is the SugarEmailAddress.php file is setting one out of x > 2 addresses to primary, one as a reply to (?) and then deleting any others left in the $check_list array. You can see this all in the logs when debug mode is turned on.
Possible Fix
I don't have an exact fix but this is as close as I got:
It would seem that all addresses are placed in the $check_list array in SugarEmailAddress.php, then at line 698 they enter an if statement where a primary address is selected, and also a reply to address (This part I'm not sure about, but I'm guessing that's what happens at 701). These addresses are unset at line 704, leaving all the rest of the addresses in the $current_links array. When the array reaches 730, the array is not a conversion, and is not empty, so it passes the conditionals and those links are then deleted. Issue #6983 seemed to believe the if statement at 730 shouldn't always pass, but I don't know enough to about the intended functionality to determine whether this is the issue, or if the issue is that these addresses were supposed to be removed from $current_links before it reached that point.
SuiteCRM/include/SugarEmailAddress/SugarEmailAddress.php
Lines 697 to 738 in 12a5b11
Steps to Reproduce
Context
This bug has ended up deleting about a hundred contact emails for my company. We did not realize the leak, as most contacts don't have 3 or more emails. I personally from that standpoint would say that this is high priority due to the potential for data loss. In the meantime, we will have to strip most workflow functionality.
Your Environment
The text was updated successfully, but these errors were encountered: