Reports That Combine Process and Object Data

Add a lookup field to the object you want to report on in the Flow Instance object

Create a Custom Report type that combines your data source with Flow Instance

Fill in required values on the New Custom Report type > click 'Next'

Set up the following object relationships > click 'Save'

“A” Object is the data source

“B”, “C” and “D” objects are from our package objects

When creating reports using this Report Type, you will primarily use the Flow Instance History object, which is the bottom set of fields:

Most Common Fields:

Actual Complete Date Value – date/time indicating when the step was completed

Actual Start Date Value – date/time indicating when the step was started

*Assigned To Name – Name of individual or group step was assigned to

*Completed By Name – Name of user that completed step

Due Date – Due date of the step

Duration – elapsed duration of step in hours (for completed steps this is the total duration between Actual Start Date and Actual Complete Date, and for active steps this is the duration from Actual start Date to the current time)

Is System – indicates the step is an automatic step

Late – checkbox field indicating a step is Late. Corresponds to the red squares in the Progress Dashboard.

Planned Duration – Duration defined in Process Designer (using d/h/m like 1d 4h 30m)

Status – indicates if step is In Process, Pending or Completed status

Step: Name – Name of the step

Swimlane Name – Name of the swimlane


*Assigned To Name  and Completed By Name fields are to be added manually to the Flow Instance History object, along with Apex code to populate their values on step assignment / step completion:

http://w-r.screenstepslive.com/s/12930/m/72945/l/1277625-pre-requisites-for-assigned-to-name-completed-by-name-reporting

Create a Report using your new Custom Report Type

New report represents both Process and Object data:

If you want to report on process instances that have already run or are in process, you can run the following script to update the Flow Instance records and insert the lookup:

List<WR_BPM__Flow_Instance__c> records = [select WR_BPM__Object_Type__c, WR_BPM__Object_Id__c from WR_BPM__Flow_Instance__c];
Set<String> localFields = new Set<String>{'step__c', 'flow__c', 'lock_parent_step__c', 'parent__c', 'parent_step__c', 'parent_step_action__c'};
       
        Map<String, String> lookupsMap = new Map<String, String>();
        for(Schema.sObjectField field : WR_BPM__Flow_Instance__c.getSObjectType().getDescribe().fields.getMap().values())
        {
            Schema.DescribeFieldResult fieldDescribe = field.getDescribe();
            if(fieldDescribe.getType() != Schema.DisplayType.REFERENCE || !fieldDescribe.isCustom() || localFields.contains(fieldDescribe.getLocalName().toLowerCase())) continue;
           
            lookupsMap.put(String.valueOf(fieldDescribe.getReferenceTo()[0]).toLowerCase(), fieldDescribe.getLocalName());
        }
       
        if(lookupsMap.size() == 0) return;
       
        for(Integer i = 0; i < records.size(); i++)
        {
            String fieldName = lookupsMap.get(records[i].WR_BPM__Object_Type__c.toLowerCase());
            if(fieldName == null) continue;
           
            records[i].put(fieldName, (String.isEmpty(records[i].WR_BPM__Object_Id__c) ? null : records[i].WR_BPM__Object_Id__c));
            System.debug(fieldName);
        }
WR_BPM.AbstractTrigger.Disabled = true;
update records;
Click to copy

0 Comments

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.