What's happening here is that because your code is running in the same execution context as the update to the record that initiated the approval process, the DML for it hasn't been "committed" to the database. See Order of Execution in the Apex Developer Guide to help you follow along with what's happening.
After any Before Insert/Update Triggers, Validation and Duplicate Record Rules run on the record being submitting for approval. The record is then "conditionally saved" to the database. It's a tentative save, not a "commit" to the database. It's at this point I'd expect to see the code for the Approval Process to be initiated (see Approval Processing in the Apex Developer Guide).
This is also the point in the execution context when the After Update trigger will fire. Note that both of these processes happen in the same execution context. In the execution context of the record being submitted for approval, it's not going to be committed to the database, until long after the AfterUpdate trigger has finished running. Workflow, Processes, and numerous other things will be run against the record before the update is "committed" to the database 12 steps in the order of execution later!
At this point, should something happen, the entire Save can still be rolled back for both the record being submitted and insertion of the new Approval Process Instance. As such, it's not possible to query an Id for the latter during the same execution context.
Initiating an Approval Process is what sets the status to 'Started'. It won't be until a successful ProcessResult
operation completes that a query will be returned with results that show it as 'Pending'.
What you could do to work around this, is use an @future
call to move the query to an asynchronous method that later updates the new custom object record at a later time. Have the method run the query to retrieve the Id of the approval process instance and update the new record on the custom object with it.
You may also want to consider moving most all of this to an asynchronous process since it doesn't sound as though it's something you need immediate updates on.
Best Answer
You are corrected that statuses Submitted and Pending mean the record is in the approval process but not yet approved.
NoResponse: If the approval step requires unanimous approval and one approver rejects the request, the value of this field for the other approvers changes to NoResponse. Likewise, If approval is based on the first response and an approver responds, the value of this field for the other approvers changes to NoResponse
Reassigned: Sent to a delegated approver in the approval process