Hi,
I created a new subpanel in the module created in Studio, a new query is associated with this subpanel, everything works, but what I would like is:
the query currently refers to the table of the created module, but instead I would like to use another table in the DB, I tried to replace the name of another table in the SELECT, but it gives me an error
the list generated in the subpanel: when I click on a row, this row expands with “+” to show more info
I wish that at the end of each column there was a sum of the data above. Example:
Date N pieces produced N pieces discarded N pieces delivered
2020-02-03 100 5 95
2020-02-06 150 0 150
2020-03-10 120 10 110
TOT 370 15 355
<?php
function get_query($params) {
global $app;
$controller = $app->controller;
$bean = $controller->bean;
$query = "
SELECT *
FROM test //I would like to replace this table with another, but not with another module
WHERE test.id = '$bean->id'
";
return $query;
}
?>
When you are using direct SQL you can do any query whatsoever. you can test your query first in phpMyAdmin and then put it in the PHP code once you know it’s working.
If you are getting an SQL error please share the Query and the exact error and I can try to help you out.
Yes, that’s what I did … the query works in phpmyadmin.
As I said above, if I insert the module table on which I am operating, there is no problem, but if I want to query a different table, this is the error in suitecrm.log:
Error retrieving TEST list: Query Failed: (
SELECT *
FROM activity
WHERE activity.id = ‘33’
) ORDER BY test.id asc LIMIT 0,10: MySQL error 1054: Unknown column ‘test.id’ in ‘order clause’
This is the mistake if i use the method you suggested:
Mysqli_query failed.
03/17/20 16:35:36 [8180][1][FATAL] Error running count query for TEST List: Query Failed: (): MySQL error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘)’ at line 1
03/17/20 16:35:36 [8180][1][FATAL] Exception handling in C:\xampp\htdocs\SuiteCRM\include\MVC\Controller\SugarController.php:400
The query is the one, without count … also, trying to launch the query again, ORDER BY TEST.ID (name of the module) is proposed, while in the query there is the name of the table (activity):
03/17/20 18:16:17 [8180][1][DEBUG] process_union_list_query: (Array) ORDER BY TEST.id asc
Sorry, I’m lost. I don’t understand what’s happening there.
I suggest that you try to get the example from that site working exactly as it is, just to confirm you get it right, and it works. Then you start changing it bit by bit until you get the effect you want.
actually I started from that, as it was, but it didn’t work, then I used what I posted to you at the beginning and it worked…
Sorry,
I would like to ask you, is it possible to use a complex query and make it appear in a subpanel? Of the type:
select a.id, a.date, a.type
when 1 then ‘first’
when 2 then ‘second’
end as type,
(select pg.n_pc where type = 1) as qty_first,
(select pg.n_pc where type = 2) as qty_second,
from pieces as pg, activity as a
where
(pg.id = 33) and a.id = pg.id
and how to make it appear in the subpanel with custom header: