Adding Columns dynamically to Salesforce Reports

痴心易碎 提交于 2019-12-11 14:11:47

问题


I need to add columns to a salesforce report dynamically(based on particular conditions). I'm planning to do this with a trigger that is looking for my conditions. My two questions,

  1. Is it possible to adding columns dynamically for a Report?
  2. Can we schedule triggers based on time intervals instead of database updates?

Thanks, BR Madura


回答1:


I'm not aware of any possibility to manipulate Reports from Apex. Report definitions can be retrieved and modified with Metadata API (the one used in Eclipse IDE for example) but that means you'd have to use hacks since Metadata API is not easily available in Apex.

It's a kind of "known problem" and many people have already researched it:

  1. http://boards.developerforce.com/t5/Apex-Code-Development/Is-it-possible-to-call-Metadata-API-from-Apex-code-Getting-Error/td-p/119412
  2. https://github.com/financialforcedev/apex-mdapi - looks really interesting I'd say
  3. https://salesforce.stackexchange.com/questions/1082/has-anyone-ever-successfully-invoked-the-metadata-api-from-within-apex

Do you really think that some kind of "dynamic report" is a valid solution for business need though? I mean - users would be confused if they added some columns to the report and next day the report definition will change wiping out their work...


As for the other question - you probably shouldn't use the word "trigger" ;) If you want some Apex to run in time intervals you should have a lookt at job scheduling (write a class that implements Schedulable) and then you can schedule it to run at specific times. Without special tweaking the job can fire even every hour.

Of course there's also option of time-based workflows that would perform a field update and cause some real trigger to fire but that's very data-centric - no guarantees that it will run at time intervals.



来源:https://stackoverflow.com/questions/13447682/adding-columns-dynamically-to-salesforce-reports

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!