Have notes written under Contracts and Contacts appear on the Accounts view

Hi All

I am trying to make it so all notes associated with accounts appear on the history tab.

For example if you write a note on a contract (I added additional relation field on the notes element).

The notes appear on contacts and contracts. But do not appear on the account.

Anyone have a simple solution?

Princeps

Doing some more tests I am having the same problem with tasks, if I have tasks assigned to an opportunity or contract they do not show up under the Accounts summary tab.

I know I could likely replicate the notes using workflow, (which would mean my system would have 2 sets of notes per note this will not work for my audit trail)

The solution above also does not work for discreet tasks on contracts or opportunities. Having duplicate tasks creates more work and confusion.

Does anyone have a way of the accounts show all the related tasks, notes and contracts that are related to them??

Thank you

Princeps

You don’t have to duplicate records, you can just add relationships to Accounts also, so they show on the Accounts subpanels. You can do this with Workflows, or from Logic hooks if you need more control.

It is also possible to customize subpanels and alter the query they use. This way you could make them include also indirectly-related records.

This requires a bit of PHP coding: https://suitecrm.com/suitecrm/forum/suitecrm-7-0-discussion/19222-subpanels-cases#66668

Hi pgr

Thank you for your advice. I have tried creating relationships one to many from accounts to tasks and one to many from accounts to notes (and vice versa)

But when I create the notes in one section. They do not appear system wide (even when I link them using relationship fields.)

I am trying to create a 360 view of an account from the accounts tab. Any tasks and notes associated with the account showing up on that page.

I thought Activities would show the all the tasks associated with its contacts, contracts and opportunities. and History the notes and attachments, does seem to work though.

For example: If I create a note in Accounts and link it via a relate field (with relationship set up) to a contract or task, it only appears in the Account. This creates a problem for users as notes and tasks can be hidden when viewing one or the other.

I haven’t used logic hooks yet, are they how this is normally solved? I know from looking this up that Sugar CRM had a similar issue, but could not find a solution in their forums.

Princeps

Logic hooks basically do what Workflows do, but you get more control since you can code whatever you want.

So you could use either one to apply a logic like “when a note is created, create a relationship to Accounts”. The first relationship (note to contact, for example) would be created automatically because the Note is being made from within the contact’s page. The Workflow/Hook would take care of the second one.

I’m not sure how this is done, you’ll have to try different things until you get it to work.

You might mess up your system with too many relationships, so please also consider the other option I mentioned above, tweaking the subpanel query to include indirectly related accounts.

Hi pgr

I am trying to do it. I am a little concerned I might not put the right Notes or Tasks ref in the correct locations.

Can you tell me if these look correct.

custom/Extension/modules/Accounts/Ext/Layoutdefs/Notes.php

<?php

$layout_defs["Accounts"]["subpanel_setup"]['notes'] = array(
    'order' => 80,
    'module' => 'Notes',
    'sort_order' => 'asc',
    'sort_by' => 'first_name, last_name',
    'subpanel_name' => 'default',
    'get_subpanel_data' => 'function:getRelatedLeadsQueryData',
    'function_parameters' => array(
    'import_function_file' => 'custom/modules/Accounts/GetNotesSubpanelData.php',
    'link' => 'leads'
    ),
    'add_subpanel_data' => 'Note_id',
    'title_key' => 'LBL_Notes_SUBPANEL_TITLE',
    'top_buttons' => array(
        array('widget_class' => 'SubPanelTopCreateLeadNameButton'),
        array('widget_class' => 'SubPanelTopSelectButton',
            'popup_module' => 'Opportunities',
            'mode' => 'MultiSelect',
        ),
    ),
);

custom/modules/Accounts/GetNotesSubpanelData.php

<?php
require_once 'custom/modules/Accounts/BuildNotesSubpanelQueryService.php';

function getRelatedNotesQueryData($param){
    $service = new BuildNotesSubpanelQueryService();
    return $service->buildQuery($param);

new file
custom/modules/Accounts/BuildNotesSubpanelQueryService.php

<?php

class BuildNotesSubpanelQueryService
{

    public function __construct()
    {}

    public function buildQuery($param)
    {
        global $app;
        $controller = $app->controller;
        $bean = $controller->bean;
        $query = "
            SELECT *
            FROM leads
            WHERE notes.account_id = '$bean->id'
              AND notes.status not in ('converted')
              AND notes.deleted = 0
               ";
        return $query;
    }
}

I used the label LBL_NOTES_SUBPANEL_TITLE, will this work?

If I replace NOTES for TASKS will that work?

Thank you for looking at my attempt

Princeps

You’re going too fast, and you seem a bit lost…

I am afraid I can’t go into this sort of detail helping out each person here on the forums… sorry :frowning:

About the language labels, it’s easy, and you can read the Developer Guide, Language chapter.

Then I advise you to start from the existing Notes subpanel files, instead of copying my example which are for Leads. For example, Notes don’t have a “converted” field.

Good luck!