0

We are starting to run Leads through an Approval process and want to report on them (of course!).

Is it possible to show other fields on the report than the one Related To? It shows the Lead Name, which is not relevant to our process - Company is the meaningful field. Others would be nice, too. Any work around appreciated, thanks.

2
  • What report type are you using for this?
    – cropredy
    Commented Dec 9, 2014 at 20:39
  • I have used Custom report type on ProcessInstance.
    – jaw999
    Commented Dec 9, 2014 at 21:21

1 Answer 1

0

jaw999

The issue you are having is that ProcessInstance.targetObjectId is a polymorphic relationship to other sObjects (including Lead in your example) and OOB SFDC reports won't let you build a custom report type that will traverse that polymorphic lookup relationship

Assuming you need a report like the ones in the SFDC help , I'd suggest you write a Visualforce page / controller that executed two SOQL to populate a single inner class for whatever reporting output you want

The VF page can be launched from a home page custom link in the sidebar

Query 1

  SELECT Id, targetObjectId, (SELECT Id, StepStatus, Comments FROM Steps)
    FROM ProcessInstance where ...
  save results in a map of targetObjectId to ProcessInstance and
  save results in a map of ProcessInstanceId to targetObjectId

Query 2

 Select id, company, email, lastname from Lead 
    where id IN targetObjIdToPIMap.keySet()

Lastly, merge results of the Query2 with the maps from Query1 into a list of some inner class containing your reporting data. Use VF pageBlockTable/dataTable/repeat to construct a pleasing format

Details of writing the actual VF page/controller are left as an exercise to you

3
  • Understood. I guess the logical development would be a report type that starts with Leads (or other object) and could choose then as children the approval objects.
    – jaw999
    Commented Dec 10, 2014 at 15:14
  • yes, except you can't define such a report type as of V32
    – cropredy
    Commented Dec 10, 2014 at 17:17
  • I know, it's the first solution I tried.
    – jaw999
    Commented Dec 10, 2014 at 21:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .