Select button in subpanel

Hi,
I modified the button inside a subpanel like this:

array (
	'widget_class' => 'SubPanelTopSelectButton',
	'mode' => 'MultiSelect',
	'initial_filter_fields' => array('id' => 'id_advanced'),
	'field_to_name_array' => array('id' =>$this->_focus->id),
)

in this way, the filter starts from a selection based on the current id.
The first problem was that if I performed a search without entering any parameters, the id was ignored and a list of all the ids and not just the current one appeared, I solved this problem by inserting the line above:

'field_to_name_array' => array ('id' => $this -> _focus-> id),

and in module popupdefs:

if (isset($_REQUEST['request_data']) && !empty($_REQUEST['request_data'])) {
	$tmp = json_decode(html_entity_decode($_REQUEST ['request_data']), true);

	if (!empty($tmp['field_to_name_array']['id'])) {

		$where_param = 'id_cantiere LIKE "'. $tmp ['field_to_name_array']['id']. '"';
	}
}

and further down:

$popupMeta = array (
	'moduleMain' => $module_name,
	'varName' => $object_name,
	'orderBy' => $_module_name. '.Name',
	'whereClauses' => array (
		'name' => $_module_name. '.Name',
	)
	'whereStatement' => $where_param,
	'searchInputs' => array ($_module_name. '_number', 'name', 'priority', 'status'),
);

everything works fine, but if I select a record from the search list, the popup disappears and nothing happens, I expected the subpanel to be filled only by the selected element.
Furthermore, if I click again on the select button and do a search without setting any field, the list of all the ids and not just the current one is displayed and the field

$Tmp ['field_to_name_array']['id']

it is empty.

Please, can you help me, thank you.

Update:

as for the ID field that was empty at a second access, I resolved by taking into consideration the URL that remains instead enhanced:

$tmp_url = json_decode(html_entity_decode ($_REQUEST['request_data']), true);

and after some operations on the string containing the URL:

$tmp_url['passthru_data']['return_url']

I get the ID inside it.
The general problem however remains, when I select a record from the list at the bottom of the search popup, the popup closes and nothing happens.

Please, do you have any ideas to solve?

Sorry, can you explain better where you are in the app? What you click to do these steps, or maybe post some screenshots. I am lost about your question…

We are in subpanel and I have replaced the “create” button in its menu with “select”, now, by clicking on the selection button, a popup appears which should search for a record by setting parameters within the same popup.
The search inside the popup works, below the list of records appears, the problem is that if I select a record, the popup closes and nothing happens.
I expected that once the record was selected, the popup would close and only the selected record would appear in the subpanel.

When you have the pop-up open, keep an eye on your browser’s Developer tools, Network tab. When you click to select (closing the pop-up) you will see an entry with the server request that is generated. Follow that to the place in the code that handles the result.

If you have difficulty finding it please post here the full URL and request parameters (you can click the line in the network tab to examine the POST params)

on the net appears:

http: //localhost/suitecrm/index.php? sugar_body_only=1&module=<module_name>& subpanel=<subpanel_name>&action=SubPanelViewer&inline=1&record=4968

That should probably go through

include/SubPanel/SubPanelViewer.php

Check if you can see your parameters there.

And eventually it should call display function from here:
include/SubPanel/SubPanel.php

from what I see, from the files you have indicated, the query is passed correctly, but the record of the row I click is missing, that is, the query works, but an additional parameter should be added at the time of the click, which identifies that record , because otherwise that query returns the entire list.
How do I pass that extra parameter when I click?

I don’t know, sorry. You’ll have to follow the code. It’s a bit complicated because it has bits of Javascript and bits of PHP. Remember to examine the POST parameters from the browser. Try to compare the normal case where it works with your customized case.

I tried to insert a “select” button inside another subpanel, but this time I haven’t customized it.
What I noticed is that if I look for an ID in the popup and select it, this record is added in the subpanel to those already present.
In my case, since my choice should be made on a list already present in the subpanel, there is no new record to add, because that record is already present.
Now I wonder, is it a correct purchase? Can you change it so that only the selected record or records appear in the subpanel list?

This doesn’t sound like “the SuiteCRM way” of doing things. The subpanels always show all the relationships to a related module. The “select” pop-up is actually a “select a record to create a relationship”, it is not a filter on the subpanel list, which is what you’re talking about.

Here is an example of changing the query for the subpanel, I don’t know if you can achieve something more through a different approach:

this is something I had already tried, but it allows you to “fill” the subpanel with the data deriving from the query created. I was interested in switching from the search popup and based on the chosen parameters, the subpanel was filled, as happens in the listview with the filter.
It can not be done?

Anything can be done,this is fully open-source.

But I don’t think it is an easy task, and I’ve never seen a tutorial for this… :frowning:

ok, thanks for your availability … if by chance you happen to have news about it, write here :disappointed:

1 Like