1

I need to make a page in SuiteCRM (v7.9 -- based loosely on Sugar 6.5 CE) that has a list of objects (of a custom module), with checkboxes in front of each one. So far, so good: that's a standard ListView.

The catch is that only some records should be in the list (filtering on whether there is an associated row in a related custom module/object).

This page needs to be distinct from the "regular" list for this module, which should indeed list all records.

It seems to me it makes sense to use a custom "action" to access this page view, and I can get my custom action code to fire with the right URL.

But I don't see how to hook in the filtering. At first, it looked like the process_record logic hook might be helpful here, but it just gives the bean for every record to be displayed. Unless there's a flag "display this record" that I'm not seeing, that's not so helpful.

Ideally, of course, I'd like to be able to inject a different WHERE clause in my custom controller action before calling

parent::action_listview();

to display the page, but I'm not seeing doc to indicate how that might work. I would include source code, but so far, the line above is everything (but boilerplate) that's in the controller.php file.

Jeffiekins
  • 569
  • 6
  • 14
  • Do you want to have a complete custom view with your own html or just default filtering a listview ? – mrbarletta Mar 20 '18 at 00:54
  • @mrbarletta I _think_ what I need to do can be accomplished by letting the users use the sorting features that come with a default listview. OTOH, if you want to mention where to look (for doc or code) or how to approach it if custom HTML is needed, that would be very welcome. – Jeffiekins Mar 20 '18 at 14:32
  • 1
    So far, I'm finding programming for SuiteCRM to be very stressful, because "the book" leaves so many gaps, and there's little other doc specific to SuiteCRM, and it's very hard for a noob to know which Sugar CE doc applies to SuiteCRM and which doesn't. I mean, seriously, I've programmed professionally in more than a dozen languages, and this is one of my more frustrating starting-out experiences. And I've done _a lot_ of PHP and plenty of JS before this. – Jeffiekins Mar 20 '18 at 14:35
  • @Jeffiekins have you tried using view.list.php? – Varun May 10 '18 at 08:12
  • @Jeffiekins could you explain how you created a custom action in the first place? – orangecaterpillar Dec 16 '19 at 22:03

2 Answers2

0

Create a copy of listview in custom folder and then override the listview's listViewProcess() method and insert your query there:

function listViewProcess()        // generating listview 
{
    $this->processSearchForm();
    if($this->where==''){
        $this->where.="leads.status='Converted'";
    }
    $this->lv->searchColumns = $this->searchForm->searchColumns;
        if(!$this->headers)
            return;
    $this->lv->setup($this->seed, 'custom/modules/Leads/ListView/ListViewGeneric.tpl', $this->where, $this->params);
    echo $this->lv->display();
}

More info: http://wiki-crm-forum.com/forum/viewtopic.php?f=2&t=9420&p=32674&hilit=listViewProcess&sid=21907ecd28734a726f61f7017a7e9a24#p32674

Another tested working example can be found here: How to hard code the where condition in list view ,basic search,advance search in sugar CE

P.S: I'm not so sure about "v7.9 -- based loosely on Sugar 6.5 CE" I'd say it's 95% identical apart from API stuff

Robert Sinclair
  • 4,550
  • 2
  • 44
  • 46
0

for custom modules in SuiteCRM.

You may change in function create_new_list_query.

Ashish Dwivedi
  • 109
  • 2
  • 10