If the comment log feature canât be used, does anyone have any suggestions on how to get a timestamp to appear every time someone adds a new piece of text to a text area within a specific module?
Hi,
have you considered using the audit feature? It would keep track of each change and it would display the old value, the new value, who did the change and the respective timestamp in a popup-window (viewable per record). Itâs an inbuilt feature and just needs to be activated.
otherwise, you do that with a workflow:
on-save, with repeated runs
action: save the current field value in a parameter. Prepend your timestamp like this:
I like your idea of using a workflow to do this. Could you possibly give me a little more insight on what I would need to put for my condition and the specific action I would need to perform?
Thatâs pretty close to what I am trying to accomplish, however the workflow @crmspace suggested is exactly what I am looking for. Thank you for the fast reply!
I added a condition in the meantime, so the workflow is only triggered when someone is actually modifying the field.
Btw, you could make this field âread onlyâ too (as your users could currently delete/modify the whole history):
create a new field (temp_text).
show temp_text only in EditView
a second field should be added to the DetailView (complete_text), but not to the EditView
on save
prepend the temp_text field to the second field with the timestamp (nearly the same formula as above).
and empty the temp_text field.
Not tested, but this way, your users can add new comments in the empty field, and on-save, the temporary field is merged into the complete history (a non-modifiable field).
E: would work in general, but I wasnât able to insert a linebreak/new line in my formula, otherwise I would have shared that approach too.
Thank you so much for providing me with the workflow screenshot. I followed your design and the timestamp applied great. I am interested in this statement as well.
Btw, you could make this field âread onlyâ too (as your users could currently delete/modify the whole history):
create a new field (temp_text).
show temp_text only in EditView
a second field should be added to the DetailView (complete_text), but not to the EditView
on save
prepend the temp_text field to the second field with the timestamp (nearly the same formula as above).
and empty the temp_text field.
I would like to try this so I could prepend a new note to the top of the detailview of the description box. I have already declared the detail view âContact Notesâ to be âread onlyâ and have my temp_text field set to be cleared on save and hidden from the detail view.
The text I input into the temp_text field transfers over to the âContact Notesâ field just fine, but when I go to add a new line, temp_text writes over my first note that I had saved. Do you have any suggestions on how to get the âContact Notesâ field to keep older notes from being deleted by the temp_text field?
there is no new line for the newly added comment, its just prepended. Iâve tried some ideas, but wasnât able to accomplish more (maybe someone here as additional ideas).
If you consider code-changes too btw, it would be very easy to do this feature as a logic hook.
Thank you for all your help! Having a logic hook create the new line sounds like a good idea. Iâm new to developing so I havenât really dove into Logic Hooks but Iâm going to give it a shot. Would it be easier to have the Logic Hook create the timestamp too or should I leave the workflow as is and just make the hook create a new line?
Hi,
we can also assist you in writing that hook if you encounter problems, just give it a try.
But to answer your question: no, deactivate your workflow and do everything from within the hook, its the more reliable solution (and you have full freedom in what you do!).
I am very new to Logic Hooks and donât quite know how to get this done. I have added these lines to my logic_hooks.php file in /custom/modules/contacts:
Then I created a new file called My_Logic_Hooks.php in the same directory with the following code:
<?php
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class My_Logic_Hooks {
function AddNewLine($bean, $event, $arguments) {
$bean->description = $bean->description . "\r"; // both of these worked
}
}
Hi,
I changed my code and entered in the name of my new comment field. After running a quick repair and rebuild I am not seeing any results show up. Do I need to enable Logic Hooks anywhere in the code or settings?
The only code changes I have done have been creating this Logic Hook in C:\SuiteCRM\custom\modules\Contacts
logic_hooks.php:
<?php
// Do not store anything in this file that is not part of the array or the hook version. This file will
// be automatically rebuilt in the future.
$hook_version = 1;
$hook_array = Array();
$hook_array['before_save'] = Array();
$hook_array['before_save'][] = Array(1, 'Store values', 'custom/modules/Contacts/My_Logic_Hooks.php', 'My_Logic_Hooks', 'AddNewLine' );
// position, file, function
$hook_array['before_save'] = Array();
$hook_array['before_save'][] = Array(6, 'Contacts push feed', 'modules/Contacts/SugarFeeds/ContactFeed.php','ContactFeed', 'pushFeed');
$hook_array['before_save'][] = Array(77, 'updateGeocodeInfo', 'modules/Contacts/ContactsJjwg_MapsLogicHook.php','ContactsJjwg_MapsLogicHook', 'updateGeocodeInfo');
$hook_array['after_save'] = Array();
$hook_array['after_save'][] = Array(7, 'Update Portal', 'modules/Contacts/updatePortal.php','updatePortal', 'updateUser');
$hook_array['after_save'][] = Array(77, 'updateRelatedMeetingsGeocodeInfo', 'modules/Contacts/ContactsJjwg_MapsLogicHook.php','ContactsJjwg_MapsLogicHook', 'updateRelatedMeetingsGeocodeInfo');
?>
and My_Logic_Hooks.php:
<?php
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class My_Logic_Hooks {
function AddNewLine($bean, $event, $arguments) {
$bean->description = date("Y-m-d H:i:s") . ': ' . $bean->temp_text_c . "\r" . $bean->description;
}
}
The only other code change I have done was adjusting the editviewdefs.php and detailviewdefs.php files in every module to accommodate for a 4-column layout instead of 2-column.
If it still doesnt work, please have a look in your logfiles and validate first if your newly created file (My_Logic_Hooks.php) is owned by the correct user (if youâre using unix).
E: it just came to my mind that this hook would add a new line on each save. Therefore, I would add a validation first, like: