Applications don’t have an ID until they’re sent to the network.
You can use the txId to make an Indexer call and find the created-application-index
In JavaScript it would look like this:
let sentTxn = await indexer.lookupTransactionByID(txId).do();
let appId = sentTxn['created-application-index'];