This topic contains 1 reply, has 1 voice, and was last updated by William Radi 5 years, 7 months ago.
- Topic
Hello guys!
Is it possible to add a sql query in the datagrid event listener?
That would be the query:
1234567SELECT COALESCE(t2.first_name, ' ') || ' ' || COALESCE(t2.last_name, '')FROM ibv_household_member AS t1JOIN orocrm_contact AS t2 ON t2.id = t1.contact_idWHERE t1.household_id IN (SELECT DISTINCT t3.household_idFROM ibv_household_member AS t3WHERE t3.contact_id = t0.id)AND t1.responsible = 't' LIMIT 1And, for while, my event listener is like that:
123456789101112131415161718192021namespace Ibv\Bundle\RdContactBundle\EventListener\Datagrid;use Oro\Bundle\DataGridBundle\Event\BuildBefore;use Oro\Bundle\DataGridBundle\Datasource\Orm\OrmDatasource;use Doctrine\ORM\EntityRepository;use Doctrine\ORM\Query\Expr\Join;class RdGridFields{public function onBuildBefore(BuildBefore $event){$config = $event->getConfig();$query = $config->getOrmQuery();$query->addSelect(SELECT COALESCE(t2.first_name, ' ') || ' ' || COALESCE(t2.last_name, '') FROM ibv_household_member....);$config->offsetAddToArrayByPath('[columns][newColumn]', ['label' => 'rd.contact.household_responsible.grid.label']);}}If possible, how to do it?
Thanks! :D
The forum ‘OroCRM’ is closed to new topics and replies.