How to enable a custom dashlet for a custom module?

Hello, we have a Sugar customer who wants to enable one of our custom dashlets for a custom module in their Sugar instance.

They installed our Fanatically Zen integration (integrates Zendesk and Sugar) which comes with a Zendesk Ticket Dashlet. When viewing a Contact, you're able to see the related Zendesk Tickets in a custom Sugar dashlet. 

In our dashlet metadata, we define the modules our dashlet can be used in (Contacts, Accounts, Opportunities, Leads, Prospects). 

What's the best way to add the customer's custom module to that list?

Is there a Sugar dashlet extension (something in the Ext framework) that could be used to append data to the filter module metadata?

Or would we need to ship a custom package of our integration that includes their custom module in the filter?

Thanks!

  • Maybe you can try to create a dashlet in the custom directory of the custom module which basically extends your dashlet for the js controller and where in the metadata you add the current module in the setttings part ?

  • Good idea, I didn't think about trying that. Conceptually it seems like that should work, but I haven't been able to get it to work.

    I think I'll end up creating a separate package for the client that overwrites our dashlet metadata file. Whenever they update our integration, they'll just need to reinstall their custom package. The only difference in the package will be the added custom module name to the viewable modules array. I think this will have to do for now.

    Thanks!

  • This is probably the easiest Chad. You may be able to do something like checking if the module exists then use one metadata array and otherwise use another. 

    This would usually work for viewdefs but not sure about a dashlet. Probably worth a test to hopefully avoid a split.

  • Thanks Shad. Maybe I missed something but I couldn't find the right combo to get it to work through the custom/module folder

    You did give me an idea though. We store a config array for the dashlet in the config table that defines how each view should retrieve the data needed to render the dashlet. The config is per module, so my thought was to grab that config data and pull out an array of modules from that and add it to the viewdef array. But I'm not sure viewdefs likes the dynamic nature of this. Only way I can get my new module to show up is if I manually type it out in the viewdef file.

    Here's what I tried: https://gist.github.com/chadhutchins/bc27ad961733072dd0d22a478c5e7043 

    Any ideas why something like that wouldn't work?

  • And I'm a dummy! Noticed the issue right when I hit submit on that last post...

    It's suppose to be something like:

    'module' => array('Contacts','Accounts','Leads')

    I replaced it with:

    $modules = array('Contacts','Accounts','Leads');

    'module'=>array($modules) // array inside an array

    Instead of 

    $modules = array('Contacts','Accounts','Leads');

    'module'=>$modules

    That did the trick! Should be able to make this work through our configs no code changes. Much better!

    Still not sure how "best practice" dynamic code is in viewdefs like this ¯\_(ツ)_/¯

  • Nice one Chad. And actually you aren't actually creating any additional directories here or causing anything to create the module simply adding the module to the array shouldn't have any impact if the module doesn't exist. I was thinking of adding dynamic by doing a check if the module is in the $moduleList parameter the.

    Something like this. Again not sure if that will work though.

    if ($has_module) {

    $viewdefarray1

    }

    else {

    $viewdefarray2

    }

  • That's a good call, just make it available for any module. That would work well with this type of dashlet. Thanks for the ideas!