Is there a Simple note Module ?

Hey there, im looking for a simple note module for every account. like this :

Really a easy to use note for every account. I’ve got the informations textarea, but user have to type their name and the date.

I know the history sub pannel but I found it very complex for my need. I dont need a document attachment or something special. Just a text area.

Maybe I can add a before save hook, who add user + date & time before every line in the description field…

Hope someone have the same need.

According to your requirement… why is the “Description” not enough?

Another possibility is to use the “Notes” module, from the “History” subpanel, but make sure you only use the “Subject” field, so that everything is directly visible in the subpanel. You don’t have to attach any files.

I don’t know what you mean by the “informations” text area. Is that something you added through Studio?

Yes sorry the information text area is description. (I just changed the name).

This text area can do the job, but I need to customize it to make it easy for the user, I need to add date + user before his new entry.
This way I will have something like this:
10/10/2010 By User X : blablabla1
20/10/2010 By User XX : blablabla2
30/10/2010 By User XXX : blablabla3

Maybe I can to this in JS, will let you know !

Try my suggestion: use the Notes module, from the History subpanel. If necessary hide the field containing the longer description text inside the note, to force people to just use the subject.

You get a nice list that has user names and dates, and you can sort, filter, etc.

It’s also easy to make these appear in a separate subpanel, to avoid confusion with the other items in history (emails,etc)

Okay,

I will try to customize the history subpannel, cause fr now this module handle a lot of thing, file, Achriv Email, filter etc… I dont need that at all so I will try to customize this a lot !

Thanks PGR.

Make a new subpanel just for Notes, copy from this example:

https://suitecrm.com/suitecrm/forum/developer-help/11352-how-to-add-a-target-lists-subpanel-to-leads-or-contacts-etc#70833

The relationship already exists, you just need a separate subpanel to avoid the complexity of “History”.

Thanks that the best way I think.

I’ve tryed to customize the code from your link but for now its not working, I get the subpannel, cant find the already existing note (created from history subpannel), the sub pannel is empty with the default dashlet icon, and without title.

<?php
//https://suitecrm.com/suitecrm/forum/developer-help/11352-how-to-add-a-target-lists-subpanel-to-leads-or-contacts-etc#70833


$layout_defs['Accounts']['subpanel_setup']['account_notes'] = array(
        'order' => 1,
        'sort_order' => 'desc',
        'title_key' => 'LBL_DEFAULT_SUBPANEL_TITLE',
        'subpanel_name' => 'default',
        'module' => 'Notes',
        'get_subpanel_data' => 'account_notes',
        'top_buttons' => array(
                array('widget_class' => 'SubPanelTopButtonQuickCreate'),
        )
);
?>

Also made
en_us.customaccounts_notes_subpanel.php
fr_FR.customaccounts_notes_subpanel.php

With code :

<?php
$mod_strings['LBL_DEFAULT_SUBPANEL_TITLE'] = 'Notes';
?>

But its not working… Any idea ?

Hhm I think this is because the Accounts_Notes relationship is a Flex relate, not a full relationship, doesn’t have a account_notes table, so it won’t work this way.

Maybe try adding a one-to-many relationship from Studio between the two modules. This will add the subpanel for you, so remove the subpanel definition files first.

You were right. Accounts_Notes does not exist in the DB, strange thing is that in the studio/relationships I can find this “Accounts_Notes” relation.

So I created a new one (wich created a new table accounts_notes_1_c)

And that code in the layoutdef :

 // created: 2019-07-31 11:04:49
$layout_defs["Accounts"]["subpanel_setup"]['accounts_notes_1'] = array (
  'order' => 100,
  'module' => 'Notes',
  'subpanel_name' => 'default',
  'sort_order' => 'asc',
  'sort_by' => 'id',
  'title_key' => 'LBL_ACCOUNTS_NOTES_1_FROM_NOTES_TITLE',
  'get_subpanel_data' => 'accounts_notes_1',
  'top_buttons' => 
  array (
    0 => 
    array (
      'widget_class' => 'SubPanelTopButtonQuickCreate',
    ),
    1 => 
    array (
      'widget_class' => 'SubPanelTopSelectButton',
      'mode' => 'MultiSelect',
    ),
  ),
);

Time to customize the Note plugin to fit my need.

Last question, do you know If I can delete that “SubPanelTopSelectButton” cause there is no use for me, I’ll never select an existing note. IDK if I can delete it directly from “/custom/modules/Accounts/Ext/Layoutdefs/layoutdefs.ext.php”

Anyway, I’ve done it in /custom/Extension/modules/Accounts/Ext/Layoutdefs/accounts_notes_1_Accounts.php

Currently trying to show the Name instead of the username in the subpannel.

You did well to change the TopButton in custom/Extension, if you had changed it in the other place it wouldn’t have survived a QR & R.

To get the name you need to go get the value from the related table (users), so this might help:

http://urdhva-tech.blogspot.com/2013/02/showing-related-modules-related-data.html

Thanks for your answer. Will check this page.

Last question, to make it a little bit like a “chat” I would like to let the user be able to delete they entry directly from the subpannel. the delete button under modify only delete the relationship (wich make orphan entry). Is theyre a way to make this button compltetly delete a record ?

Sure, but you’ll have to custom code all of it.

Maybe you can get some ideas from the Dashlets where this is possible, since Dashlets are also based on List views.

There’s a “Close” X button on the Tasks and on the Calls dashlets, which directly writes to the database a record update. It’s an update, not a delete, but that shouldn’t be too hard to change.

Good luck with this and please write a brief tutorial for us if you can get it to work :wink:

1 Like

Thought it would be easier.

I think I’ll make a workflow. If a note dont have an account set, put delete=1. In my case it will be faster, cause I dont think to have the time to make a custom thing once again :dry:

Arg. The workflow is not striking from the subpannel, only when I edit the note directly from the note view’s.

I’ve write this on my TO DO list, I dont have the time for this, from now my user will note be able to delete a note, or they will have to dig into the listview from the note module lol.

Tryed to make it like in this topic :

https://suitecrm.com/suitecrm/forum/developer-help/10549-add-a-custom-action-to-the-buttons-on-the-right-of-a-subpanel-row

But in /include/generic/SugarWidgets/SugarWidgetSubPanelDeleteButton.php I can see it call a JS function :

$html = "<a id=\"$unique_id\" onclick='return sp_del_conf();' href=\"javascript:sub_p_del('$subpanel', '$module_name', '$record_id', $refresh_page);\">".$app_strings['LNK_DELETE']."</a>";

IDK if I will succes at creating a new button, for now users cant delete a note.

Okay so catched some time to fix the delete button.

It was really easy in fact, in /SuiteCRM/include/generic/SugarWidgets we have Remove Button, wich remove the relation, and Delete Buton wich completly delete an entry (what I want for my note).

In the studio I only can add Remove_button so I’ve done it in the code :

In /SuiteCRM/custom/modules/Notes/metadata/subpanels/Account_subpanel_accounts_notes_1.php I’ve added my delete button :

  'delete_button' => 
  array (
    'width' => '2%',
    'vname' => 'LBL_DELETE',
    'default' => true,
    'widget_class' => 'SubPanelDeleteButton',
  ),

And so with this methode I now know how to create custom subpannel button If I want to.

1 Like

So I have done everything with this module, I just discovered a “bug” a user can edit/delte every note, even if he is not the author.

I want to make it like so : A user can edit/delete only his message (so if he is the authors of the note).

Do you know how to proceed ? For now I made a custom JS function to hide the modify button if the note “created by” ID isnt the current user ID. But its not really secured.

Tryed the roles configuration but there is not option “If Authors Only”.

Hope you can help @PGR !

EDIT : Strange thing is that if I put in the roles config edit and delet on “owner” the user cant edit and delete every notes, even his own note.

I dont know if its a bug that I have to report on github, would need someone to test on another instance.

Check which security groups are attached to the Note, they also affect the outcome, not just the User’s roles and the Role definitions.