Sometimes you need to do a bit of magic to to pull together the right query to get the subpanel data you need. I’ve seen the question come up on the forums, and found a nice solution proposed by poster erop. There was a small issue of it not being upgrade-safe, so I took that solution and tweaked it for that.
First off, there’s the entry in the subpaneldefs, which has specific parts it in called out in the comments to indicate that we’ll be using a custom function to get the data we need.
Now comes the function itself, which thanks to the Ext Framework can be dropped in any .php file in the custom/Extension/application/Ext/Utils/ directory. Note the one thing you’ll want to do is get a reference to the current $bean object, which is easy to access thru the global scope as noted in the example below.
If you are on a version of Sugar prior to 6.3, you will need to drop the function in the custom/include/custom_utils.php file and change the above file reference to this file location as well.
With a Quick Rebuild and Repair, you’ll be up and going with your custom query.