Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom subpanels not loading data until the page is reloaded #10365

Open
pablonr11 opened this issue Feb 23, 2024 · 0 comments
Open

Custom subpanels not loading data until the page is reloaded #10365

pablonr11 opened this issue Feb 23, 2024 · 0 comments
Labels
Status:Fix Proposed A issue that has a PR related to it that provides a possible resolution

Comments

@pablonr11
Copy link
Contributor

Issue

When you try to open a subpanel introduced using a custom layour def the subpanel first loads empty. Once you reload the page mantaining the subpanel opened the data loads correctly. The same occurs when you try to order the subpanel by some column.

Expected Behavior

When opening/ordering the subpanel the data should load the same way as the other subpanels in the CRM

Actual Behavior

Since the record is not retrieved on the bean you can't acceed the id in the _focus on the layout defs you can't run the custom query properly.
This makes the subpanel load empty.

Possible Fix

In include/SubPanel/SubPanelViewer.php around line 86 changing

$bean = BeanFactory::getBean($module);

for

$bean = BeanFactory::getBean($module, $record);

This will retrieve the current record in the bean which will allow the custom subpanel layout_def to acceed the id in $this->_focus.

Steps to Reproduce

  1. Create a custom layout_def subpanel that loads data using a function and makes use of $this->_focus->id as a function parameter. For example
$layout_defs['act_Empleados']['subpanel_setup']['act_empleados_act_vacaciones_empleados'] = array(
    'order' => 100,
    'module' => 'act_vacaciones_empleados',
    'subpanel_name' => 'default',
    'sort_by' => 'date_entered',
    'sort_order' => 'desc',
    'title_key' => 'LBL_ACT_EMPLEADOS_ACT_VACACIONES_EMPLEADOS',
    'get_subpanel_data' => 'function:getEmployeeHolidays',
    'add_subpanel_data' => 'act_vacaciones_empleados_id',
    'generate_select' => false,
    'top_buttons' => array(),
    'function_parameters' => array(
        'import_function_file' => 'custom/modules/act_vacaciones_empleados/subpanelFunctions.php',
        'employee_id' => $this->_focus->id,
        'return_as_array' => 'false'
    ),
);

Context

I was implementing a custom subpanel that shows some employee holidays and I needed to show only the future holidays so i needed to filter the ones that already happened.

In most cases the default relationships that you can build with studio/module builder are enough. I think the times a custom subpanel is needed are low. I'll mark this as a medium issue.

Your Environment

  • SuiteCRM Version used: 7.14.2
  • Browser name and version: Chrome Version 122.0.6261.57
  • Environment name and version: PHP 8.1. MySQL 8.0.30
  • Operating System and version: Windows 10
pablonr11 added a commit to pablonr11/SuiteCRM that referenced this issue Feb 23, 2024
…age is reloaded

This bug makes custom subpanels that uses $this->_focus->id as a function parameter not load correctly
@gemartin21 gemartin21 added the Status:Fix Proposed A issue that has a PR related to it that provides a possible resolution label Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status:Fix Proposed A issue that has a PR related to it that provides a possible resolution
Projects
None yet
Development

No branches or pull requests

2 participants