Idea Summary
Currently as i understand the function behaves differently if called from within a page PLSQL proc of via a database PLSQL proc.
Use Case
But I wanted to use the same code multiple times within the app and also via and Oracle Job. So i created a proc to do the required sending of emails and attaching a url of the called page.
Thus causing the problem of having one version to be called by APEX and another version via a job process. Both the same based code block but one proc has to add the missing part of the URL. So the links work.
Preferred Solution (Optional)
Add another flag to the function to determine how it's being called so the correct URL is created.