As I understand the UUID (the unique document number) isn’t passed from DTTG to Shortcuts since version 3 due to incompatibility with some apps when a document is shared to those apps. But you can have Shortcuts ‘pull’ the UUID from a selected document, i.e. you first need to open that document in DTTG.
Be aware I use this workaround on multiple devices and noticed older devices require split screen to work well (I presume due to lack of memory). Newer devices can run the Shortcut with the x-callback without split screen, but you might just try for yourself whether you require split screen. But be advised, if it doesn’t you might need to restart the device to get things back in working order.
After Shortcut has obtained the UUID, you can flow it into a variable and obtain the document title with the UUID as well. With both the title and UUID you can construct the markdown in a text containing the variables of both. I presume you can share the result immediately to the app where you want to store the markdown.
Personally speaking, I think the UUID should be send from the sharesheet again as it can be filtered out with Shortcuts in those circumstances that the UUID is misinterpreted by some apps.
IMO apps that misinterpret text (the document title) and erronously replace it with a URL (x-devonthink-item://UUID) should fix things on their side. But perhaps there’s a good reason those apps can’t.
I was able to simplify the shortcut. It still just uses clipboard. DEVONthink get item isn’t working correctly on iOS15 and throws an error whenever I try to use the shortcut in a share sheet to grab the item link.