In this tutorial, I will explain how to Auto fill a relate field from parent module to custom child module
Custom Hello module has the relationship with opportunity and Account.
Relationships :
1. One to many relationships between Hello module and Opportunity
2. One to many relationships between Hello module and Account.
Opportunity detail view has Hello module subpanel as shown in the image below. When using click on create button of Hello subpanel
quick create form appears.
Quick create form has Opportunities field fill with opportunity name.
The question is : How to auto fill Accounts when quick create view is rendered ?
blog-autofill
Account field name – test_hello_accounts_name
Account field id – test_hello_accountsaccounts_ida
Steps
1. Copy file – include/generic/SugarWidgets/SugarWidgetSubPanelTopButtonQuickCreate.php to past file to
custom/include/generic/SugarWidgets/SugarWidgetSubPanelTopButtonQuickCreate.php
Add following code before foreach loop which create input fields from $additionalFormFields.
if($relationship_name == ‘test_hello_opportunities’){
$additionalFormFields[‘test_hello_accounts_name’]=$defines[‘focus’]->account_name;
$additionalFormFields[‘test_hello_accountsaccounts_ida’]=$defines[‘focus’]->account_id;
}
It will work only for subpanel under opportunity module. It can not work for subpanel under Account module.
As Account module has one to many relationships with Opportunity.
0 responses on "Auto fill a relate field from parent to custom child module"