The Approval processes were recently changed and I don't want all the former approvers to have the note on their user record.
3 answers
Linda - ah, no worries. Actually, I hadn't thought through the fact that Data Loader won't export relationship queries. So, here is what I did (and I hope someone else has a better solution)
1. Go to Developer Console
2. Debug | Open Execute Anonymous Window
3. Paste in this code:
String res = '';
for ( ProcessInstance pi: [SELECT Id, Status,(SELECT Id, ActorId, OriginalActorId, StepStatus, Comments FROM StepsAndWorkitems)
FROM ProcessInstance where Status IN ('Pending','Hold','Reassigned','NoResponse')] ) {
for (ProcessInstanceHistory pih : pi.StepsAndWorkItems) {
res = res + pi.status + ',' + pih.actorId + '\n';
}
}
System.debug(LoggingLevel.INFO,res);
4. Click Execute (in lower right of window)
5. File | Download Log
The downloaded log will look like this:
29.0 APEX_CODE,INFO;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,INFO;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
Execute Anonymous: String res = '';
Execute Anonymous: for ( ProcessInstance pi: [SELECT Id, Status,(SELECT Id, ActorId, OriginalActorId, StepStatus, Comments FROM StepsAndWorkitems)
Execute Anonymous: FROM ProcessInstance where Status IN ('Pending','Hold','Reassigned','NoResponse')] ) {
Execute Anonymous: for (ProcessInstanceHistory pih : pi.StepsAndWorkItems) {
Execute Anonymous: res = res + pi.status + ',' + pih.actorId + '\n';
Execute Anonymous:
Execute Anonymous: }
Execute Anonymous: }
Execute Anonymous: System.debug(LoggingLevel.INFO,res);
13:25:56.043 (43426919)|EXECUTION_STARTED
13:25:56.043 (43433980)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex
13:25:56.044 (44104251)|SOQL_EXECUTE_BEGIN|[2]|Aggregations:1|select Id, Status, (select Id, ActorId, OriginalActorId, StepStatus, Comments from StepsAndWorkitems) from ProcessInstance
13:25:56.123 (123941735)|SOQL_EXECUTE_END|[2]|Rows:151
13:25:56.244 (244840951)|USER_DEBUG|[9]|INFO|Pending,005d0000001nmllAAA
Pending,005d0000001nmllAAA
Pending,005d0000001nmllAAA
Pending,005d0000001nmllAAA
Pending,005d0000001nmllAAA
Pending,005d0000001nmllAAA
Pending,005d0000001pRE3AAM
Pending,005d0000001nBgkAAE
...
Starting at the USER_DEBUG line, you can copy/paste the rest into a text file and then import into Excel. The second column is the actorId which you will compare against the separately run export of Userids. You should be able to see how to add additional columns to the result based on the code sample.
Other solutions that don't work:
1. SFDC Workbench but it too will not allow export of relationship queries to CSV; workable if you only have a handful of active approvals at a given point in time.
2. Custom report types: Can't build a reportType on ProcessInstance
Vote up this idea: https://success.salesforce.com/ideaView?id=08730000000BrquAAC - looks popular