Tracker module does not track deleted accounts and as a result MergeRecords module does not track all entries when merging as it only tracks the Save on the parent account.
Platform is SugarCRM CE 5.2.0d on Windows and MS-SQL.
The changes required for this are all in the file /data/sugarbean.php starting at line 4264 or there-abouts:
Changing the code to include both a log entry for deletions and the tracker entry.Code:4264 $query = "UPDATE $this->table_name set deleted=1 , date_modified = '$date_modified' where id='$id'"; 4265 $this->db->query($query, true,"Error marking record deleted: "); 4266 $this->mark_relationships_deleted($id); 4267 4268 // Take the item off the recently viewed lists</span>
The log entry could be changed to only debug, error, or warning level, but I figure that 'delete' will be one of those things we will constantly be chasing for our beloved end-users.Code:4264 $query = "UPDATE $this->table_name set deleted=1 , date_modified = '$date_modified' where id='$id'"; 4265 # thowden 20090518: Added for logging of deletions 4266 $GLOBALS['log']->info('Deletion ' . $id . ' query : ' . $query); 4267 # end thowden 4268 $this->db->query($query, true,"Error marking record deleted: "); 4269 $this->mark_relationships_deleted($id); 4270 # thowden 20090518 added to tracker for deletions 4271 $this->track_view($current_user->id, $this->module_dir, 'deleted'); 4272 # end thowden 4273 // Take the item off the recently viewed lists</span>
Hand-in-hand with deletion is the concept of restoration and for good measure this can also be tracked.
Further down the file: noting that line numbers shown here vary as they are already changed compared to the original file due to the inclusion of the code above.
Changes to:Code:4289 $query = "UPDATE $this->table_name set deleted=0 , date_modified = '$date_modified' where id='$id'"; 4290 $this->db->query($query, true,"Error marking record undeleted: "); 4291 4292 // call the custom business logic
Now you can review in both the sugarcrm.log or whatever you call your log file and in the Tracker table in your SugarCRM database. I would note that in both the delete and restore processes I have not allowed for the error of being unable to delete/restore. It would be more robust with some error-handling and detailed log/track messages. But for the moment I'll assume each transactions suceeds.Code:4295 # thowden 20090518: Added for logging of restorations 4296 $GLOBALS['log']->info('Restoring ' . $name . ' ' . $value . ' query : ' . $query); 4297 # end thowden 4298 $this->db->query($query, true,"Error marking record undeleted: "); 4299 # thowden 20090518 added to tracker for restores 4300 $this->track_view($current_user->id, $this->module_dir, 'restored'); 4301 # end thowden
For the merge process details to be really useful we wanted to add a trigger in the database to run some scripts. In order for the trigger to function it needs to have a unique record that it 'knows' means that the merge transactions have completed.
So I added a new entry to the Tracker database. File to modify is
modules\MergeRecords\SaveMerge.php
Find line 118 in the file:
... and add the followingCode:118 $GLOBALS['log']->debug("Merged record with id of ".$return_id);</span>
This completes a merged accounts transaction set for any number of merged accounts with a mergecomplete transaction. The database trigger is linked to that entry and recognises all the transactions by the monitor_id column value which is unique for a transaction set.Code:118 $GLOBALS['log']->debug("Merged record with id of ".$return_id); 119 # thowden 20090518 added to tracker for mergecomplete 120 $mergesource->track_view($current_user->id, 'MergeRecords', 'mergecomplete'); 121 # end thowden
To query the Tracker table try using something like the following and modify the date value to something more appropriate.
Next I need to tackle the process for merging Contacts.Code:select * from tracker where convert(char(10),date_modified,112)>='20090520'


LinkBack URL
About LinkBacks



Reply With Quote

Bookmarks