Internal URL link within the application

I’m trying to build out a LMS from SuiteCRM and I want to make it migration/upgrade safe. I have custom modules, but I want to add a url as a field that links to a specific document. I can create the url through a textblock manually, but would rather use a logic hook to get the URL dynamically. I have also tried the route of using a relate field, but again it’s a manual process at this point. I know you can use the below to get the site url, but I’m needing to set the dynamic url to something like $doc1 = $siteUrl . ‘documents/record/’ . $document1Id …Where I get the ID from the document through SQL, but then to have it present as a URL.

global $sugar_config;
             $siteUrl = $sugar_config['site_url'];