1
votes

I am struggling to find where to start w.r.t my following problem.

In SFDC reports, there is an "export details" button to export a user chosen report into csv or xls formats. I want to modify this xls file (for example, encrypt it) before user downloads it. I guess I can achieve this using Apex triggers. My questions are:

  1. How can I add an Apex trigger which is triggered upon a user clicking this "export details" button?
  2. How can I access the xls contents in this Apex trigger code where I want to encrypt them?

I extensively searched in Apex user guide and many other sources. I can not find how to add triggers to standard SFDC buttons.

Thank you very much in advance.

2
Hi @Mera, there is a new stackexchange site specific to Salesforce at salesforce.stackexchange.com. Come join the community over there! :) - Ralph Callaway
Thank you very much Ralph. - MeraNaamJoker

2 Answers

2
votes

How can I add an Apex trigger which is triggered upon a user clicking this "export details" button?

This isn't currently possible. First triggers are related to database actions and not user interface events. You can override the behavior for a lot of buttons using a view override, but unfortunately that's also not available for report buttons.

Workarounds

While you can't alter the behavior of the standard report experience, there is a new Reporting API that was just released by Salesforce that allows you to programmatically get the contents of a report. Using that you could build your own "encrypted report download" tool to accomplish this.

For more information, checkout this answer on Salesforce Stackexchange on accessing reports through the api. And in the future, post to Salesforce Stackexchange first!! That's where the community is these days ;)

0
votes

Trigger can only be called when you do some dml operation in salesforce, clicking a button has no concern with the trigger calling,