How do I check if a record of a custom object is locked through an approval process ? I know i can use the ProcessInstance to access my approval processes, but I can't check if it is locked or unlocked.
You could create an "In Approval Process?" checkbox and set it to true in the Initial Submission Actions and then set it to false in the Final Approval, Rejection, and Recall Actions of approval processes.
Another workaround is to activate 'Track Field History' for the custom object, then if the record is locked it will be shown in the custom object History table.
For example if you have a custom object "Project" with API Name "Project__c", if you activate 'Track Field History' the table "Project__History" will be automatically created and you can check if a record is locked using this query:
(with the ParentId value in the WHERE clause the Id of the Custom Object Record.)
and checking that Field is equal to locked: