Are you using a formula field in the native Airtable interface, the filterByFormula feature of the Standard REST API, or one of the other APIs?
If you are using a formula field in the native Airtable interface, you do not need to use the record id.
If you are using one of the other APIs, the linked record field is stored as an array of objects. Refer to the API documentation for the exact format.
If you need more help, could you please post some screen shots of your base and your code?