Leveraging the Dashboards to provide one click search results.

Opublikowane
2011-05-11 09:22
Written by
theMusician - member of the CiviCRM community - view blog guidelines

CiviCRM is a really nice product for the developer in me because it allows you to create the exact solution as requested by a customer. I have been learning the ins and outs of the system the best I can over the past three weeks so when my customer requested the ability to click a button on the main navigation to see pending and active cases I figured it would be easy.


My plan was to simply create a search, using the Find Cases search that had active users selected and then copy and past the URL, using that for the new navigation link. This is an example of such a link. http://example.com/civicrm/case/search?_qf_Search_display=true&qfKey=df0f48b3543e50e0a7b4a553f8d9eba8_6911
I was thwarted by the session key which makes the link unusable for somebody else. Obviously, this was not the best solution. After messing around with a few ideas for a while I figured there had to be an easy way to do this. In Civi, I have found that I try to reinvent the wheel when someone else has already done so.

 

This is when I turned to the IRC channel, #civicrm, if you haven't utilized this great resource, try it next time you are looking for some help. I posted my question and Dave Greenberg, responded with the idea to try Smart Groups. Smart Groups allow you to create groups based on certain selections from the Advanced Search screen. The idea was that by finding the active or pending cases this way, I could use the static link provided by the Smart Group. No dice. Case types are not yet integrated into the advanced search.

 

Then Dave told me about the dashboards. Most components have a dashboard, for my use case, I needed to leverage the case dashboard. When you load the dashboard, there is a summary table, the "Summary of Case Involvement." As long as you have one created case you can use the dash to help craft static URLs.

Click a number under any of the columns, if you haven't changed any deafaults in your Case.xml file you might click a number under OnGoing. The link takes you to a summary of all OnGoing cases. Looking in your URL bar you will notice a perfectly crafted static URL.


http://example.com/civicrm/case/search?reset=1&force=1&status=1&type=1&all=0
 

The interesting part of the URL is the status and type key. These refer to case statuses and types that you configure in your xml file. For my customer, I wanted to see all Active and Pending cases, regardless of type. So my URLs ended up looking like.

 

http://vpfa-dev/fa-drupal7/drupal-7.0/civicrm/case/search?reset=1&force=1&status=6 (for Pending Cases)

http://vpfa-dev/fa-drupal7/drupal-7.0/civicrm/case/search?reset=1&force=1&status=4 (for Active Cases)

 

Notice that I dropped off the type because that is not important for my search. You can either look in the database to get the numbers that relate to the status and type or just change them in the url and observe the results. This can be done with other dashboards such as the Events and Contribute boards as well.


Thanks to Dave Greenberg for sharing his thoughts and ideas as well as the larger Civi community for helping me learn this great product.

Filed under