Why not do it the other way around, where the template being loaded is what actually contains the complex logic? Then you can embed the rest of the template, passing the entry_id
via an embed parameter.
Alternately, write a simple plugin which performs your logic and returns the entry_id
, then put your Channel Entries tag inside of that plugin tag pair (related example hererelated example here).