function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Fabio PalladinoFabio Palladino 

Get Initial submitter of an Approval through SOQL

Hi all,
is it possible to get the initial Approval Process submitter for a specific object through apex code ?
I searched around but I could not find a SOQL statement for this purpose.

Thanks in advance

Fabio
 
Best Answer chosen by Fabio Palladino
UC InnovationUC Innovation
Yes, you can do something like this:

SELECT TargetObjectId, SubmittedById FROM ProcessInstance WHERE TargetObjectId = '<some SFDC record ID>'

The TargetObjectId is the record ID that is being submitted for approval.  The SubmittedById should be the ID of the User that submitted the approval request.

All Answers

RaidanRaidan
UC InnovationUC Innovation
Yes, you can do something like this:

SELECT TargetObjectId, SubmittedById FROM ProcessInstance WHERE TargetObjectId = '<some SFDC record ID>'

The TargetObjectId is the record ID that is being submitted for approval.  The SubmittedById should be the ID of the User that submitted the approval request.
This was selected as the best answer
Fabio PalladinoFabio Palladino
Hi UC, it works !! The field "SubmittedById" is not documented in the API documentation posted by Raidan.
It appear like an "Hidden" field.

Thanks a lot
Fabio
UC InnovationUC Innovation
Glad that it works.  I got the field from the Force.com IDE.