{"id":6007,"date":"2021-07-19T03:53:58","date_gmt":"2021-07-19T03:53:58","guid":{"rendered":"https:\/\/tst-blog.myenterprise.in\/?p=6007"},"modified":"2025-01-13T09:44:43","modified_gmt":"2025-01-13T09:44:43","slug":"sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship","status":"publish","type":"post","link":"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/","title":{"rendered":"SugarCRM Tutorial on categorizing records in two Subpanels for a single \u201cOne to Many\u201d relationship"},"content":{"rendered":"<p class=\"has-drop-cap is-cnvs-dropcap-bg-light\">We all know that when a one-to-many relationship exists between two modules, Sugar will create a subpanel in the Parent Module and a relationship table in the database to store the related records ids to load that records in the subpanel. This is pretty powerful but in some situations, there are requirements to create two subpanels with only one relationship and categorize the related records into those two subpanels. This blog will explain how to create two subpanels with one relationship and categorize related records into those subpanels.<\/p>\n\n\n<hr class=\"wp-block-separator has-text-color has-gray-200-color has-alpha-channel-opacity has-gray-200-background-color has-background is-style-cnvs-separator-double\"\/>\n\n\n\n<h3 id=\"an-example-scenario\" class=\"wp-block-heading\">An Example Scenario:<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s take an example where your customer has a requirement to show Opportunities related to Accounts in two subpanels in one subpanel with all the open Opportunities and the other with all closed Opportunities.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now let us see how to build two subpanels for Opportunities in Accounts modules by using standard relationship in the studio.<\/p>\n\n\n\n<h4 id=\"step-1-create-metadata-for-custom-subpanel\" class=\"wp-block-heading\">Step 1: Create Metadata for Custom subpanel.<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">We know that there is already a one-to-many SugarCRM standard relationship between Accounts and Opportunities in SugarCRM and the relationship metadata is defined in modules\/Accounts\/vardefs.php<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now to create a new subpanel and to categorise Closed opportunities and Open Opportunities let us create a file in following path and add the below code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>custom\/Extension\/modules\/Accounts\/Ext\/Vardefs\/.php<\/strong><\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#242134;color:#cecbee\">PHP<\/span><span role=\"button\" tabindex=\"0\" data-code=\"&lt;?php\n$dictionary['Account']['fields']['accounts_closed_opportunities'] = array(\n    'name' =&gt; 'accounts_closed_opportunities',\n    'type' =&gt; 'link',\n    'relationship' =&gt; 'accounts_opportunities',\n    'source' =&gt; 'non-db',\n    'module' =&gt; 'Opportunities',\n    'bean_name' =&gt; 'Opportunity',\n    'vname' =&gt; 'LBL_ACCOUNTS_CLOSED_OPPORTUNITIES_TITLE',\n    'link-type' =&gt; 'many',\n    'side' =&gt; 'left',\n);\" style=\"color:#e0def4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki rose-pine\" style=\"background-color: #191724\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #31748F\">&lt;?php<\/span><\/span>\n<span class=\"line\"><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">dictionary<\/span><span style=\"color: #908CAA\">[<\/span><span style=\"color: #F6C177\">&#39;Account&#39;<\/span><span style=\"color: #908CAA\">][<\/span><span style=\"color: #F6C177\">&#39;fields&#39;<\/span><span style=\"color: #908CAA\">][<\/span><span style=\"color: #F6C177\">&#39;accounts_closed_opportunities&#39;<\/span><span style=\"color: #908CAA\">]<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #EB6F92; font-style: italic\">array<\/span><span style=\"color: #908CAA\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #F6C177\">&#39;name&#39;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=&gt;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">&#39;accounts_closed_opportunities&#39;<\/span><span style=\"color: #908CAA\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #F6C177\">&#39;type&#39;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=&gt;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">&#39;link&#39;<\/span><span style=\"color: #908CAA\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #F6C177\">&#39;relationship&#39;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=&gt;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">&#39;accounts_opportunities&#39;<\/span><span style=\"color: #908CAA\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #F6C177\">&#39;source&#39;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=&gt;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">&#39;non-db&#39;<\/span><span style=\"color: #908CAA\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #F6C177\">&#39;module&#39;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=&gt;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">&#39;Opportunities&#39;<\/span><span style=\"color: #908CAA\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #F6C177\">&#39;bean_name&#39;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=&gt;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">&#39;Opportunity&#39;<\/span><span style=\"color: #908CAA\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #F6C177\">&#39;vname&#39;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=&gt;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">&#39;LBL_ACCOUNTS_CLOSED_OPPORTUNITIES_TITLE&#39;<\/span><span style=\"color: #908CAA\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #F6C177\">&#39;link-type&#39;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=&gt;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">&#39;many&#39;<\/span><span style=\"color: #908CAA\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #F6C177\">&#39;side&#39;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=&gt;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">&#39;left&#39;<\/span><span style=\"color: #908CAA\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #908CAA\">);<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">The above code defines a custom relationship metadata with a name and tells the system to use the relationship which is used by the one-to-many relationship between accounts and opportunities. So that the related records are loaded into this custom subpanel form accounts_opportunities table.<\/p>\n\n\n\n<h3 id=\"step-2-custom-subpanel-title\" class=\"wp-block-heading\">Step 2: Custom Subpanel Title<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">As we want to differentiate Open Opportunities and Closed Opportunities, Let us rename the new subpanel as Closed Opportunities. To do this create a file in following path and add the below code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">custom\/Extension\/modules\/Accounts\/Ext\/Language\/en_us..php<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#242134;color:#cecbee\">PHP<\/span><span role=\"button\" tabindex=\"0\" data-code=\"&lt;?php\n   $mod_strings['LBL_ACCOUNTS_CLOSED_OPPORTUNITIES_TITLE'] = 'Closed Opportunities';\n?&gt;\" style=\"color:#e0def4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki rose-pine\" style=\"background-color: #191724\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #31748F\">&lt;?php<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">   <\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">mod_strings<\/span><span style=\"color: #908CAA\">[<\/span><span style=\"color: #F6C177\">&#39;LBL_ACCOUNTS_CLOSED_OPPORTUNITIES_TITLE&#39;<\/span><span style=\"color: #908CAA\">]<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">&#39;Closed Opportunities&#39;<\/span><span style=\"color: #908CAA\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #31748F\">?&gt;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><br>The above code will set the label to the custom subpanel.<\/p>\n\n\n\n<h3 id=\"step-3-create-viewdefs-for-custom-subpanel\" class=\"wp-block-heading\">Step 3: Create Viewdefs for Custom Subpanel<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To render the custom subpanel in Accounts record view, create a new file in following path and add the below code. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>custom\\Extension\\modules\\Accounts\\Ext\\clients\\base\\layouts\\subpanels\\.php<\/strong><\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#242134;color:#cecbee\">PHP<\/span><span role=\"button\" tabindex=\"0\" data-code=\"&lt;?php\n$viewdefs['Accounts']['base']['layout']['subpanels']['components'][] = array (\n  'layout' =&gt; 'subpanel',\n  'label' =&gt; 'LBL_ACCOUNTS_CLOSED_OPPORTUNITIES_TITLE',\n  'context' =&gt; \n  array (\n    'link' =&gt; 'accounts_closed_opportunities',\n  ),\n);\n?&gt;\" style=\"color:#e0def4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki rose-pine\" style=\"background-color: #191724\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #31748F\">&lt;?php<\/span><\/span>\n<span class=\"line\"><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">viewdefs<\/span><span style=\"color: #908CAA\">[<\/span><span style=\"color: #F6C177\">&#39;Accounts&#39;<\/span><span style=\"color: #908CAA\">][<\/span><span style=\"color: #F6C177\">&#39;base&#39;<\/span><span style=\"color: #908CAA\">][<\/span><span style=\"color: #F6C177\">&#39;layout&#39;<\/span><span style=\"color: #908CAA\">][<\/span><span style=\"color: #F6C177\">&#39;subpanels&#39;<\/span><span style=\"color: #908CAA\">][<\/span><span style=\"color: #F6C177\">&#39;components&#39;<\/span><span style=\"color: #908CAA\">][]<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #EB6F92; font-style: italic\">array<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #908CAA\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">  <\/span><span style=\"color: #F6C177\">&#39;layout&#39;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=&gt;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">&#39;subpanel&#39;<\/span><span style=\"color: #908CAA\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">  <\/span><span style=\"color: #F6C177\">&#39;label&#39;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=&gt;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">&#39;LBL_ACCOUNTS_CLOSED_OPPORTUNITIES_TITLE&#39;<\/span><span style=\"color: #908CAA\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">  <\/span><span style=\"color: #F6C177\">&#39;context&#39;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=&gt;<\/span><span style=\"color: #E0DEF4\"> <\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">  <\/span><span style=\"color: #EB6F92; font-style: italic\">array<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #908CAA\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #F6C177\">&#39;link&#39;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=&gt;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">&#39;accounts_closed_opportunities&#39;<\/span><span style=\"color: #908CAA\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">  <\/span><span style=\"color: #908CAA\">),<\/span><\/span>\n<span class=\"line\"><span style=\"color: #908CAA\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #31748F\">?&gt;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">This code will give metadata for the subpanel layout.<\/p>\n\n\n\n<h3 id=\"step-4-rename-default-subpanel\" class=\"wp-block-heading\">Step 4: Rename Default Subpanel<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Now it\u2019s time  to rename our default subpanel to the Open Opportunities in Accounts module. To do this open the Sugar Instance as an admin user and go to Admin&gt; Studio&gt; Accounts&gt; Subpanels&gt; Opportunities and rename the stock subpanel from Opportunities to Open Opportunities because we are going to load open Opportunities into it.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"854\" height=\"372\" src=\"https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/10\/sugarcrm-tutorial-categorizing-records-bhea.png\" alt=\"Categorizing records in two Subpanels in SugarCRM\" class=\"wp-image-7681\" srcset=\"https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/10\/sugarcrm-tutorial-categorizing-records-bhea.png 854w, https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/10\/sugarcrm-tutorial-categorizing-records-bhea-300x131.png 300w, https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/10\/sugarcrm-tutorial-categorizing-records-bhea-768x335.png 768w, https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/10\/sugarcrm-tutorial-categorizing-records-bhea-380x166.png 380w, https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/10\/sugarcrm-tutorial-categorizing-records-bhea-550x240.png 550w, https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/10\/sugarcrm-tutorial-categorizing-records-bhea-800x348.png 800w, https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/10\/sugarcrm-tutorial-categorizing-records-bhea-600x261.png 600w, https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/10\/sugarcrm-tutorial-categorizing-records-bhea-760x331.png 760w\" sizes=\"auto, (max-width: 854px) 100vw, 854px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">After this do Quick Repair and Rebuild now you will see a new custom subpanel in Accounts Record View.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now you will see both the subpanels will load the same data, this is because we didn\u2019t add the code to filter the Opportunities based on the sales stage.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To achieve this we need to add two more attributes namely <strong>link_class<\/strong> and <strong>link_file<\/strong> in the metadata files of both stock and custom subpanels. Here, link_class is the Class Name we are using for handling relationships and <strong>link_file<\/strong> is the path for the PHP file in which the class is defined.<\/p>\n\n\n\n<h2 id=\"categorizing-the-related-records-for-subpanels\" class=\"wp-block-heading\">Categorizing the related records for subpanels<\/h2>\n\n\n\n<h3 id=\"step-1-adding-attributes-to-relationship-metadata\" class=\"wp-block-heading\">Step 1: Adding attributes to relationship metadata<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">As discussed in the above step, in this step we will add the two attributes for filtering data.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Open the relationship metadata file which was created before in following path and add these two attributes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>custom\/Extension\/modules\/Accounts\/Ext\/Vardefs\/.php<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The code will look like this,<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#242134;color:#cecbee\">PHP<\/span><span role=\"button\" tabindex=\"0\" data-code=\"&lt;?php\n$dictionary['Account']['fields']['accounts_closed_opportunities'] = array(\n    'name' =&gt; 'accounts_closed_opportunities',\n    'type' =&gt; 'link',\n    'relationship' =&gt; 'accounts_opportunities',\n    'source' =&gt; 'non-db',\n    'module' =&gt; 'Opportunities',\n    'bean_name' =&gt; 'Opportunity',\n    'vname' =&gt; 'LBL_ACCOUNTS_CLOSED_OPPORTUNITIES_TITLE',\n    'link-type' =&gt; 'many',\n    'side' =&gt; 'left',\n    'link_file' =&gt;'custom\/modules\/Accounts\/ClosedOpportunitiesForAccounts.php',\n    'link_class' =&gt; 'ClosedOpportunitiesForAccounts', \n);\" style=\"color:#e0def4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki rose-pine\" style=\"background-color: #191724\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #31748F\">&lt;?php<\/span><\/span>\n<span class=\"line\"><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">dictionary<\/span><span style=\"color: #908CAA\">[<\/span><span style=\"color: #F6C177\">&#39;Account&#39;<\/span><span style=\"color: #908CAA\">][<\/span><span style=\"color: #F6C177\">&#39;fields&#39;<\/span><span style=\"color: #908CAA\">][<\/span><span style=\"color: #F6C177\">&#39;accounts_closed_opportunities&#39;<\/span><span style=\"color: #908CAA\">]<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #EB6F92; font-style: italic\">array<\/span><span style=\"color: #908CAA\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #F6C177\">&#39;name&#39;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=&gt;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">&#39;accounts_closed_opportunities&#39;<\/span><span style=\"color: #908CAA\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #F6C177\">&#39;type&#39;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=&gt;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">&#39;link&#39;<\/span><span style=\"color: #908CAA\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #F6C177\">&#39;relationship&#39;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=&gt;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">&#39;accounts_opportunities&#39;<\/span><span style=\"color: #908CAA\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #F6C177\">&#39;source&#39;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=&gt;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">&#39;non-db&#39;<\/span><span style=\"color: #908CAA\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #F6C177\">&#39;module&#39;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=&gt;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">&#39;Opportunities&#39;<\/span><span style=\"color: #908CAA\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #F6C177\">&#39;bean_name&#39;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=&gt;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">&#39;Opportunity&#39;<\/span><span style=\"color: #908CAA\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #F6C177\">&#39;vname&#39;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=&gt;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">&#39;LBL_ACCOUNTS_CLOSED_OPPORTUNITIES_TITLE&#39;<\/span><span style=\"color: #908CAA\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #F6C177\">&#39;link-type&#39;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=&gt;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">&#39;many&#39;<\/span><span style=\"color: #908CAA\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #F6C177\">&#39;side&#39;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=&gt;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">&#39;left&#39;<\/span><span style=\"color: #908CAA\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #F6C177\">&#39;link_file&#39;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=&gt;<\/span><span style=\"color: #F6C177\">&#39;custom\/modules\/Accounts\/ClosedOpportunitiesForAccounts.php&#39;<\/span><span style=\"color: #908CAA\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #F6C177\">&#39;link_class&#39;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=&gt;<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">&#39;ClosedOpportunitiesForAccounts&#39;<\/span><span style=\"color: #908CAA\">,<\/span><span style=\"color: #E0DEF4\"> <\/span><\/span>\n<span class=\"line\"><span style=\"color: #908CAA\">);<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Do the same for stock relationship metadata. Create a new file in&nbsp; the following path and add the below code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>custom\\Extension\\modules\\Accounts\\Ext\\Vardefs\\&lt;file_name&gt;.php&nbsp;<\/strong><\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#242134;color:#cecbee\">PHP<\/span><span role=\"button\" tabindex=\"0\" data-code=\"&lt;?php\n$dictionary['Account']['fields']['opportunities']['link_file'] ='custom\/modules\/Accounts\/OpenOpportunitiesForAccounts.php';\n$dictionary['Account']['fields']['opportunities']['link_class'] = 'OpenOpportunitiesForAccounts';\" style=\"color:#e0def4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki rose-pine\" style=\"background-color: #191724\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #31748F\">&lt;?php<\/span><\/span>\n<span class=\"line\"><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">dictionary<\/span><span style=\"color: #908CAA\">[<\/span><span style=\"color: #F6C177\">&#39;Account&#39;<\/span><span style=\"color: #908CAA\">][<\/span><span style=\"color: #F6C177\">&#39;fields&#39;<\/span><span style=\"color: #908CAA\">][<\/span><span style=\"color: #F6C177\">&#39;opportunities&#39;<\/span><span style=\"color: #908CAA\">][<\/span><span style=\"color: #F6C177\">&#39;link_file&#39;<\/span><span style=\"color: #908CAA\">]<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=<\/span><span style=\"color: #F6C177\">&#39;custom\/modules\/Accounts\/OpenOpportunitiesForAccounts.php&#39;<\/span><span style=\"color: #908CAA\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">dictionary<\/span><span style=\"color: #908CAA\">[<\/span><span style=\"color: #F6C177\">&#39;Account&#39;<\/span><span style=\"color: #908CAA\">][<\/span><span style=\"color: #F6C177\">&#39;fields&#39;<\/span><span style=\"color: #908CAA\">][<\/span><span style=\"color: #F6C177\">&#39;opportunities&#39;<\/span><span style=\"color: #908CAA\">][<\/span><span style=\"color: #F6C177\">&#39;link_class&#39;<\/span><span style=\"color: #908CAA\">]<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">&#39;OpenOpportunitiesForAccounts&#39;<\/span><span style=\"color: #908CAA\">;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">In the above code, we are adding<strong> link_class<\/strong> and<strong> link_file<\/strong> attributes to stock relationship metadata.<\/p>\n\n\n\n<h3 id=\"step-2-filtering-related-records\" class=\"wp-block-heading\">Step 2: Filtering Related Records<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Now create these classes in their defined paths to load the related records. Create a new file in the following path and add the below code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>custom\/modules\/Accounts\/ClosedOpportunitiesForAccounts.php<\/strong><\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#242134;color:#cecbee\">PHP<\/span><span role=\"button\" tabindex=\"0\" data-code=\"&lt;?php\nclass ClosedOpportunitiesForAccounts extends Link2\n{\n    function __construct($linkName, $bean, $linkDef = false){\n        parent::__construct($linkName, $bean, $linkDef = false);\n    }\n    function buildJoinSugarQuery($sugar_query, $options = array()){\n        $closed_stages = array(\n            'Closed Won',\n            'Closed Lost',\n        );\n        $sugar_query-&gt;where()-&gt;in('sales_stage',$closed_stages);\n      return $this-&gt;relationship-&gt;buildJoinSugarQuery($this, $sugar_query, $options);\n    }\n}\" style=\"color:#e0def4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki rose-pine\" style=\"background-color: #191724\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #31748F\">&lt;?php<\/span><\/span>\n<span class=\"line\"><span style=\"color: #31748F\">class<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #9CCFD8\">ClosedOpportunitiesForAccounts<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">extends<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #C4A7E7; font-style: italic\">Link2<\/span><\/span>\n<span class=\"line\"><span style=\"color: #908CAA\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #31748F\">function<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #EB6F92; font-style: italic\">__construct<\/span><span style=\"color: #908CAA\">(<\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">linkName<\/span><span style=\"color: #908CAA\">,<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">bean<\/span><span style=\"color: #908CAA\">,<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">linkDef<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #EBBCBA\">false<\/span><span style=\"color: #908CAA\">){<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">        <\/span><span style=\"color: #31748F\">parent::<\/span><span style=\"color: #EBBCBA\">__construct<\/span><span style=\"color: #908CAA\">(<\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">linkName<\/span><span style=\"color: #908CAA\">,<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">bean<\/span><span style=\"color: #908CAA\">,<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">linkDef<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #EBBCBA\">false<\/span><span style=\"color: #908CAA\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #908CAA\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #31748F\">function<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #EBBCBA\">buildJoinSugarQuery<\/span><span style=\"color: #908CAA\">(<\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">sugar_query<\/span><span style=\"color: #908CAA\">,<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">options<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #EB6F92; font-style: italic\">array<\/span><span style=\"color: #908CAA\">()){<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">        <\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">closed_stages<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #EB6F92; font-style: italic\">array<\/span><span style=\"color: #908CAA\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">            <\/span><span style=\"color: #F6C177\">&#39;Closed Won&#39;<\/span><span style=\"color: #908CAA\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">            <\/span><span style=\"color: #F6C177\">&#39;Closed Lost&#39;<\/span><span style=\"color: #908CAA\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">        <\/span><span style=\"color: #908CAA\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">        <\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">sugar_query<\/span><span style=\"color: #31748F\">-&gt;<\/span><span style=\"color: #EBBCBA\">where<\/span><span style=\"color: #908CAA\">()<\/span><span style=\"color: #31748F\">-&gt;<\/span><span style=\"color: #EBBCBA\">in<\/span><span style=\"color: #908CAA\">(<\/span><span style=\"color: #F6C177\">&#39;sales_stage&#39;<\/span><span style=\"color: #908CAA\">,<\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">closed_stages<\/span><span style=\"color: #908CAA\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">      <\/span><span style=\"color: #31748F\">return<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">this<\/span><span style=\"color: #31748F\">-&gt;<\/span><span style=\"color: #E0DEF4; font-style: italic\">relationship<\/span><span style=\"color: #31748F\">-&gt;<\/span><span style=\"color: #EBBCBA\">buildJoinSugarQuery<\/span><span style=\"color: #908CAA\">(<\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">this<\/span><span style=\"color: #908CAA\">,<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">sugar_query<\/span><span style=\"color: #908CAA\">,<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">options<\/span><span style=\"color: #908CAA\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #908CAA\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #908CAA\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Sugar uses Link2 class which is defined in data\/Link2.php for handling relationships, In the above code, we are extending Link2 class and overriding the buildJoinSugarQuery function to filter the records.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The buildJoinSugarQuery function has a SugarQuery object as an argument and we can make the query using that object like above.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Do the same for the stock relationship also by adding the below code in the following path.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>custom\/modules\/Accounts\/OpenOpportunitiesForAccounts.php<\/strong><\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#242134;color:#cecbee\">PHP<\/span><span role=\"button\" tabindex=\"0\" data-code=\"&lt;?php\nclass OpenOpportunitiesForAccounts extends Link2\n{\n    function __construct($linkName, $bean, $linkDef = false){\n        parent::__construct($linkName, $bean, $linkDef = false);\n    }\n    function buildJoinSugarQuery($sugar_query, $options = array()){\n        $non_open_stages = array(\n            'Closed Won',\n            'Closed Lost',\n        );\n        $sugar_query-&gt;where()-&gt;notIn('sales_stage',$non_open_stages);\n        return $this-&gt;relationship-&gt;buildJoinSugarQuery($this, $sugar_query, $options);\n    }\n}\" style=\"color:#e0def4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki rose-pine\" style=\"background-color: #191724\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #31748F\">&lt;?php<\/span><\/span>\n<span class=\"line\"><span style=\"color: #31748F\">class<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #9CCFD8\">OpenOpportunitiesForAccounts<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">extends<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #C4A7E7; font-style: italic\">Link2<\/span><\/span>\n<span class=\"line\"><span style=\"color: #908CAA\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #31748F\">function<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #EB6F92; font-style: italic\">__construct<\/span><span style=\"color: #908CAA\">(<\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">linkName<\/span><span style=\"color: #908CAA\">,<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">bean<\/span><span style=\"color: #908CAA\">,<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">linkDef<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #EBBCBA\">false<\/span><span style=\"color: #908CAA\">){<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">        <\/span><span style=\"color: #31748F\">parent::<\/span><span style=\"color: #EBBCBA\">__construct<\/span><span style=\"color: #908CAA\">(<\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">linkName<\/span><span style=\"color: #908CAA\">,<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">bean<\/span><span style=\"color: #908CAA\">,<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">linkDef<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #EBBCBA\">false<\/span><span style=\"color: #908CAA\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #908CAA\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #31748F\">function<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #EBBCBA\">buildJoinSugarQuery<\/span><span style=\"color: #908CAA\">(<\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">sugar_query<\/span><span style=\"color: #908CAA\">,<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">options<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #EB6F92; font-style: italic\">array<\/span><span style=\"color: #908CAA\">()){<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">        <\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">non_open_stages<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #31748F\">=<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #EB6F92; font-style: italic\">array<\/span><span style=\"color: #908CAA\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">            <\/span><span style=\"color: #F6C177\">&#39;Closed Won&#39;<\/span><span style=\"color: #908CAA\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">            <\/span><span style=\"color: #F6C177\">&#39;Closed Lost&#39;<\/span><span style=\"color: #908CAA\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">        <\/span><span style=\"color: #908CAA\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">        <\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">sugar_query<\/span><span style=\"color: #31748F\">-&gt;<\/span><span style=\"color: #EBBCBA\">where<\/span><span style=\"color: #908CAA\">()<\/span><span style=\"color: #31748F\">-&gt;<\/span><span style=\"color: #EBBCBA\">notIn<\/span><span style=\"color: #908CAA\">(<\/span><span style=\"color: #F6C177\">&#39;sales_stage&#39;<\/span><span style=\"color: #908CAA\">,<\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">non_open_stages<\/span><span style=\"color: #908CAA\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">        <\/span><span style=\"color: #31748F\">return<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">this<\/span><span style=\"color: #31748F\">-&gt;<\/span><span style=\"color: #E0DEF4; font-style: italic\">relationship<\/span><span style=\"color: #31748F\">-&gt;<\/span><span style=\"color: #EBBCBA\">buildJoinSugarQuery<\/span><span style=\"color: #908CAA\">(<\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">this<\/span><span style=\"color: #908CAA\">,<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">sugar_query<\/span><span style=\"color: #908CAA\">,<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #908CAA; font-style: italic\">$<\/span><span style=\"color: #E0DEF4; font-style: italic\">options<\/span><span style=\"color: #908CAA\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E0DEF4\">    <\/span><span style=\"color: #908CAA\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #908CAA\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Once all your files are in place do a quick repair and rebuild and you are done.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"928\" height=\"479\" src=\"https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/10\/sugarcrm-records-subpanel-categorization-bhea.png\" alt=\"Step-by-step Guide: SugarCRM Subpanel Categorization\" class=\"wp-image-7680\" srcset=\"https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/10\/sugarcrm-records-subpanel-categorization-bhea.png 928w, https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/10\/sugarcrm-records-subpanel-categorization-bhea-300x155.png 300w, https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/10\/sugarcrm-records-subpanel-categorization-bhea-768x396.png 768w, https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/10\/sugarcrm-records-subpanel-categorization-bhea-380x196.png 380w, https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/10\/sugarcrm-records-subpanel-categorization-bhea-550x284.png 550w, https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/10\/sugarcrm-records-subpanel-categorization-bhea-800x413.png 800w, https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/10\/sugarcrm-records-subpanel-categorization-bhea-600x310.png 600w, https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/10\/sugarcrm-records-subpanel-categorization-bhea-760x392.png 760w\" sizes=\"auto, (max-width: 928px) 100vw, 928px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Now as shown in the above image we can see two Opportunities Subpanels, one with Open Opportunities Subpanel which filters only the Open Opportunities, and Closed Opportunities Subpanel which filters only Closed Opportunities.<\/p>\n\n\n\n<h2 id=\"conclusion\" class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This customisation will be really useful where the customer wants to categorise the Opportunities based on their sales stages. Not only in Opportunities we can customise similarly for any modules in Sugar like for example where we need to categorise Meetings, Calls, Leads etc and this is completely Upgrade safe Customisation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Get started streamlining your SugarCRM data organization today! <a href=\"https:\/\/www.bhea.com\/contact-us\" data-type=\"link\" data-id=\"https:\/\/www.bhea.com\/contact-us\">Contact Us Now<\/a>!<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"We all know that when a one-to-many relationship exists between two modules, Sugar will create a subpanel in&hellip;\n","protected":false},"author":4,"featured_media":7381,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"two_page_speed":[],"csco_singular_sidebar":"","csco_page_header_type":"","csco_appearance_masonry":"","csco_page_load_nextpost":"","csco_post_video_location":[],"csco_post_video_location_hash":"","csco_post_video_url":"","csco_post_video_bg_start_time":0,"csco_post_video_bg_end_time":0,"footnotes":""},"categories":[43],"tags":[49,47,86],"class_list":["post-6007","post","type-post","status-publish","format-standard","has-post-thumbnail","category-sugarcrm-development","tag-crm-implementation","tag-sugarcrm","tag-sugarcrm-development","cs-entry","cs-video-wrap"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>SugarCRM Tutorial : Categorizing Records in &#039;One to Many&#039; Relationship<\/title>\n<meta name=\"description\" content=\"SugarCRM Developer Tutorial to categorise sub panel records based on a single parameter. Use Sugar developer manual for feature development.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SugarCRM Tutorial : Categorizing Records in &#039;One to Many&#039; Relationship\" \/>\n<meta property=\"og:description\" content=\"SugarCRM Developer Tutorial to categorise sub panel records based on a single parameter. Use Sugar developer manual for feature development.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/\" \/>\n<meta property=\"og:site_name\" content=\"Bhea Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/bheatech\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-19T03:53:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-01-13T09:44:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/08\/bhea-sugarcrm-tutorial-categorizing-records.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1272\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ramya Katram\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bheacrm\" \/>\n<meta name=\"twitter:site\" content=\"@bheacrm\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ramya Katram\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/\"},\"author\":{\"name\":\"Ramya Katram\",\"@id\":\"https:\/\/bhea.com\/blog\/#\/schema\/person\/f00e449036a375e445c793649186c0fa\"},\"headline\":\"SugarCRM Tutorial on categorizing records in two Subpanels for a single \u201cOne to Many\u201d relationship\",\"datePublished\":\"2021-07-19T03:53:58+00:00\",\"dateModified\":\"2025-01-13T09:44:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/\"},\"wordCount\":885,\"publisher\":{\"@id\":\"https:\/\/bhea.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/08\/bhea-sugarcrm-tutorial-categorizing-records.png\",\"keywords\":[\"crm implementation\",\"SugarCRM\",\"SugarCRM Development\"],\"articleSection\":[\"SugarCRM Development\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/\",\"url\":\"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/\",\"name\":\"SugarCRM Tutorial : Categorizing Records in 'One to Many' Relationship\",\"isPartOf\":{\"@id\":\"https:\/\/bhea.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/08\/bhea-sugarcrm-tutorial-categorizing-records.png\",\"datePublished\":\"2021-07-19T03:53:58+00:00\",\"dateModified\":\"2025-01-13T09:44:43+00:00\",\"description\":\"SugarCRM Developer Tutorial to categorise sub panel records based on a single parameter. Use Sugar developer manual for feature development.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/#primaryimage\",\"url\":\"https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/08\/bhea-sugarcrm-tutorial-categorizing-records.png\",\"contentUrl\":\"https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/08\/bhea-sugarcrm-tutorial-categorizing-records.png\",\"width\":1920,\"height\":1272},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.bhea.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SugarCRM Tutorial on categorizing records in two Subpanels for a single \u201cOne to Many\u201d relationship\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/bhea.com\/blog\/#website\",\"url\":\"https:\/\/bhea.com\/blog\/\",\"name\":\"Bhea Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/bhea.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/bhea.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/bhea.com\/blog\/#organization\",\"name\":\"Bhea Technologies Pte Ltd\",\"url\":\"https:\/\/bhea.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/bhea.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/05\/Bhea_blog_logo.png\",\"contentUrl\":\"https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/05\/Bhea_blog_logo.png\",\"width\":1918,\"height\":460,\"caption\":\"Bhea Technologies Pte Ltd\"},\"image\":{\"@id\":\"https:\/\/bhea.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/bheatech\",\"https:\/\/x.com\/bheacrm\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/bhea.com\/blog\/#\/schema\/person\/f00e449036a375e445c793649186c0fa\",\"name\":\"Ramya Katram\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/bhea.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/64adc14f239923d2d69d93ddaba92b6e9e6450fb23301d04601744079db39f04?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/64adc14f239923d2d69d93ddaba92b6e9e6450fb23301d04601744079db39f04?s=96&d=mm&r=g\",\"caption\":\"Ramya Katram\"},\"url\":\"https:\/\/www.bhea.com\/blog\/author\/ramya-katram\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SugarCRM Tutorial : Categorizing Records in 'One to Many' Relationship","description":"SugarCRM Developer Tutorial to categorise sub panel records based on a single parameter. Use Sugar developer manual for feature development.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/","og_locale":"en_US","og_type":"article","og_title":"SugarCRM Tutorial : Categorizing Records in 'One to Many' Relationship","og_description":"SugarCRM Developer Tutorial to categorise sub panel records based on a single parameter. Use Sugar developer manual for feature development.","og_url":"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/","og_site_name":"Bhea Blog","article_publisher":"https:\/\/www.facebook.com\/bheatech","article_published_time":"2021-07-19T03:53:58+00:00","article_modified_time":"2025-01-13T09:44:43+00:00","og_image":[{"width":1920,"height":1272,"url":"https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/08\/bhea-sugarcrm-tutorial-categorizing-records.png","type":"image\/png"}],"author":"Ramya Katram","twitter_card":"summary_large_image","twitter_creator":"@bheacrm","twitter_site":"@bheacrm","twitter_misc":{"Written by":"Ramya Katram","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/#article","isPartOf":{"@id":"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/"},"author":{"name":"Ramya Katram","@id":"https:\/\/bhea.com\/blog\/#\/schema\/person\/f00e449036a375e445c793649186c0fa"},"headline":"SugarCRM Tutorial on categorizing records in two Subpanels for a single \u201cOne to Many\u201d relationship","datePublished":"2021-07-19T03:53:58+00:00","dateModified":"2025-01-13T09:44:43+00:00","mainEntityOfPage":{"@id":"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/"},"wordCount":885,"publisher":{"@id":"https:\/\/bhea.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/#primaryimage"},"thumbnailUrl":"https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/08\/bhea-sugarcrm-tutorial-categorizing-records.png","keywords":["crm implementation","SugarCRM","SugarCRM Development"],"articleSection":["SugarCRM Development"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/","url":"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/","name":"SugarCRM Tutorial : Categorizing Records in 'One to Many' Relationship","isPartOf":{"@id":"https:\/\/bhea.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/#primaryimage"},"image":{"@id":"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/#primaryimage"},"thumbnailUrl":"https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/08\/bhea-sugarcrm-tutorial-categorizing-records.png","datePublished":"2021-07-19T03:53:58+00:00","dateModified":"2025-01-13T09:44:43+00:00","description":"SugarCRM Developer Tutorial to categorise sub panel records based on a single parameter. Use Sugar developer manual for feature development.","breadcrumb":{"@id":"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/#primaryimage","url":"https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/08\/bhea-sugarcrm-tutorial-categorizing-records.png","contentUrl":"https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/08\/bhea-sugarcrm-tutorial-categorizing-records.png","width":1920,"height":1272},{"@type":"BreadcrumbList","@id":"https:\/\/www.bhea.com\/blog\/sugarcrm-tutorial-on-categorizing-records-in-two-subpanels-for-a-single-one-to-many-relationship\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.bhea.com\/blog\/"},{"@type":"ListItem","position":2,"name":"SugarCRM Tutorial on categorizing records in two Subpanels for a single \u201cOne to Many\u201d relationship"}]},{"@type":"WebSite","@id":"https:\/\/bhea.com\/blog\/#website","url":"https:\/\/bhea.com\/blog\/","name":"Bhea Blog","description":"","publisher":{"@id":"https:\/\/bhea.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/bhea.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/bhea.com\/blog\/#organization","name":"Bhea Technologies Pte Ltd","url":"https:\/\/bhea.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/bhea.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/05\/Bhea_blog_logo.png","contentUrl":"https:\/\/www.bhea.com\/blog\/wp-content\/uploads\/2024\/05\/Bhea_blog_logo.png","width":1918,"height":460,"caption":"Bhea Technologies Pte Ltd"},"image":{"@id":"https:\/\/bhea.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/bheatech","https:\/\/x.com\/bheacrm"]},{"@type":"Person","@id":"https:\/\/bhea.com\/blog\/#\/schema\/person\/f00e449036a375e445c793649186c0fa","name":"Ramya Katram","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/bhea.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/64adc14f239923d2d69d93ddaba92b6e9e6450fb23301d04601744079db39f04?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/64adc14f239923d2d69d93ddaba92b6e9e6450fb23301d04601744079db39f04?s=96&d=mm&r=g","caption":"Ramya Katram"},"url":"https:\/\/www.bhea.com\/blog\/author\/ramya-katram\/"}]}},"_links":{"self":[{"href":"https:\/\/www.bhea.com\/blog\/wp-json\/wp\/v2\/posts\/6007","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bhea.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bhea.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bhea.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bhea.com\/blog\/wp-json\/wp\/v2\/comments?post=6007"}],"version-history":[{"count":8,"href":"https:\/\/www.bhea.com\/blog\/wp-json\/wp\/v2\/posts\/6007\/revisions"}],"predecessor-version":[{"id":7915,"href":"https:\/\/www.bhea.com\/blog\/wp-json\/wp\/v2\/posts\/6007\/revisions\/7915"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bhea.com\/blog\/wp-json\/wp\/v2\/media\/7381"}],"wp:attachment":[{"href":"https:\/\/www.bhea.com\/blog\/wp-json\/wp\/v2\/media?parent=6007"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bhea.com\/blog\/wp-json\/wp\/v2\/categories?post=6007"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bhea.com\/blog\/wp-json\/wp\/v2\/tags?post=6007"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}