Best way to generate a report for audit logs of a field on SugarCRM On-Demand

Hello everyone,

I've tried finding out a simple way to generate a report based on tracking the dates when a particular drop-down field was changed from one value to the next. My initial research has concluded that there isn't a way to do this.

So my questions are:

1. Is it really not possible without the purchase of 3rd Party SugarCRM modules (like Sugar Outfitters)?

2. If it isn't, is it at least possible to timestamp a text field (with the status) every time the status is changed? I can later extract that and create my report using some simple Excel manipulations.

Thanks a lot.

  • Can you double-check that the folders and filename listed matches what is in your zip file? (Namely: custom/modules/Leads/LeadsLogicHooks.php) It could be a copy-paste error if you didn't name your file exactly the same as I named mine.

  • Thanks a lot it works!!! The help you lent was just unbelievably accurate!

  • Hi Alan, ist there a way to do this in Sugar CE 6.5 as well? I tried with same coding, but its not working .. nothing happens & no informations in Status_log field. I need to get a report about change state in Leadstate - for example, when does the leadstate changed from "new" to "in Process". I can see in audit log of the Lead, but a need a report about every lead of the month esp.

    Thanks for your help.

     Alan Beam

  • Hi! It's been a while, but I glanced over this and I don't see anything that jumps out to me as incompatible with CE. You'll want to make sure that the acceptable_sugar_versions regex will match with your version of Sugar. You might check your server logs, as well, in case a PHP error is being thrown during the upload/install and it isn't being relayed to the screen. Let me know how these suggestions go!

    -Alan

  • Thanks alan, i ment your example with the logic hook here. i don´t have a record view layout? How can i check if this works?

    "1. Create a custom TextArea in Admin > Studio. For reference, I named mine "status_log_c". I also added it to the Record View layout so I could verify the logic hook was working at the end.

    1. Create or edit the file custom/modules/Leads/logic_hooks.php:
      1. <?php  
      2. $hook_version = 1;  
      3. $hook_array = Array();  
      4. $hook_array['before_save'] = Array();  
      5. $hook_array['before_save'][] = Array(1, 'Store values', 'custom/modules/Leads/LeadsLogicHooks.php', 'LeadsLogicHooks', 'before_save_method');  

      If the file already exists and there is already another before_save logic hook, you'll just add line 5. If the file exists, but there is not a before_save logic hook yet, add lines 4 and 5.

    2. Create the file custom/modules/Leads/LeadsLogicHooks.php:
      1. <?php   
      2. if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');    
      3. class LeadsLogicHooks {  
      4.      function before_save_method($bean$event$arguments) {  
      5.          if($bean->fetched_row['status'] != $bean->status) {  
      6.               $bean->status_log_c .= $bean->status . "," . date("Y-m-d H:i:s") . ";";  
      7.          }  
      8.      }  
      9. }  
    3. Run the Admin > Repair > Quick Repair and Rebuild tool.

    That should do it! This will concatenate the new status and current time stamp into a text area every time the status field changes. Obviously, this can be modified to fit your purposes as needed. If you want to use the old status, reference $bean->fetched_row['status']. You can modify the delimiters (comma and semicolon used in this example), or change the module and field names as needed. Let me know if you run into any issues getting this up and running!"

  • Ah, gotcha. In Sugar 7, the Edit and Detail Views are combined into a single Record View. This should still work in CE, you would just need to add the above field into the Edit and Detail Views. Let me know if you have any other questions!

    -Alan

  • Hi alan,

    i did exactky what you wrote. I put the field "status_log" into the Edit & Detail View, but when i change the state nothing happens, the field is still empty?

    do you have any idea?

    Thanks

    daniela

  • Hi Daniela!

    We are holding a webinar for Sugar CE users and I thought that you might be interested. During the webinar, we’re going to discuss SugarCRM peculiarities, the risks associated with its usage and the ways to mitigate those risks, and also the secrets of choosing the right CRM for your company. The webinar is based on many years of our practical experience in SugarCRM development and support. I hope to see you among our attendees!

  • Hi Daniela!

    We are holding a webinar for Sugar CE users and I thought that you might be interested. During the webinar, we’re going to discuss SugarCRM peculiarities, the risks associated with its usage and the ways to mitigate those risks, and also the secrets of choosing the right CRM for your company. The webinar is based on many years of our practical experience in SugarCRM development and support. I hope to see you among our attendees!

  • Alan Beam

    Hi Alan

    Happy New Year to you !!!

    I am amazed with your in-depth knowledge of Sugar CRM.

    So, was hoping if you could help me out. The issue here is :

    I have a team of 15 people working on Sugar on-demand Enterprise (6.7.13) for handling Cases.

    So, is it possible to extract their daily wok log at the end of the day from sugar, I have tried a lot but unable to do. So, if possible, please help me with that.

    What I am looking for :

    A work log which can be exported to Excel and it should contain all the details of each ticket handled by each user.

    Please let me know if it is possible ??

    Thanks for looking.

    Regards

    Bhavya Bhushan