If you use an OOTB document upload control that contains the "On upload complete" event, such as the "BPM File Dropzone" or "BPM File Uploader", you can add the following code to the event handler to obtain the docId:
// Note even if multiple documents are uploaded, each one returns their own 'On Upload Complete' message with a single docId per message
var parser = new DOMParser();
var xml = parser.parseFromString(message, "text/xml");
var docId = xml.getElementsByTagName("output")[0].textContent.trim();
Note that as the comment above says, if multiple documents are uploaded, each one will fire the event and the logic will run separately and be able to obtain each docId. Hope that snippet helps!
------------------------------
Don Williams
------------------------------