Restrict a Note's Contact Lookup Based on the Parent Quote's Billing Account

Hello,

It is relatively easy to filter a Quote's Billing Contact Lookup based on the Quote's Billing Account. 

Add a custom filter:
../custom/Extension/modules/Contacts/Ext/clients/base/filters/basic/filterContactByParentAccount.php

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
$viewdefs['Contacts']['base']['filter']['basic']['filters'][] = array(
'id' => 'filterContactByParentAccount',
'name' => 'LBL_FILTER_CONTACT_BY_PARENT_ACCOUNT',
'filter_definition' => array(
array(
'account_id' => ''
),
),
'editable' => true,
'is_template' => true,
);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Then add that filter to the Record View:
../custom/Extension/modules/Quotes/Ext/clients/base/views/record/record.php

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
//TAI-JEK-Feb. 2021-Add an initial filter to the billing_contact_name field so it only shows Contacts related to the Billing Account.
//Loop through all panels on the Quote Layout.
foreach ($viewdefs['Quotes']['base']['view']['record']['panels'] as $i => $panel) {
//Loop through all fields on the Layout looking for the field we want to modify.
foreach ($panel['fields'] as $j => $field) {
if(is_array($field)){
if(isset($field['name'])){
$fieldName = $field['name'];
}
}
else{
$fieldName = $field;
}
if ($fieldName == 'billing_contact_name') {
//Will set the custom filter here
$viewdefs['Quotes']['base']['view']['record']['panels'][$i]['fields'][$j] =
array (
'name' => 'billing_contact_name',
'initial_filter' => 'filterContactByParentAccount',
'initial_filter_label' => 'LBL_FILTER_CONTACT_BY_PARENT_ACCOUNT',
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I'd like to do something similar for the Notes module when a Note is related to a Quote.  I could do something similar but I don't know how to get the AccountID when extending the Note's record.php.  Should I override the relate.js which would give more options for retrieving the parent Quote's AccountID, similar to this Community Post

Thank you,
Justin Kuehlthau

Parents
  • Notes module is not directaly related to Accounts, instead it is related to Contacts.

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • Hi André,

    Notes can be related to a Quote.  When viewing a Quote and clicking the plus sign in the Note Subpanel, the Note Create drawer is opened with the Related To set to the Quote.  I'd like to restrict the Contact lookup field to Contact's related to the Quote's Billing Account.

    Thank you,
    Justin Kuehlthau

  • We did that in the past. This is upgrade safe and packageScan safe but this not a simple task, It requires good development skills.

    Let me know if you would like such feature. Reach me by email/skype if you are interested on it.

    Regards

    André Lopes
    Lampada Global
    Skype: andre.lampada
Reply
  • We did that in the past. This is upgrade safe and packageScan safe but this not a simple task, It requires good development skills.

    Let me know if you would like such feature. Reach me by email/skype if you are interested on it.

    Regards

    André Lopes
    Lampada Global
    Skype: andre.lampada
Children
No Data