I'm trying to publish a custom print layout and try to unitize the dynamic text to make outputting a map easier. soon, I found this function very useful, but I tried several time and it seems that the dynamic text doesn't get transfer over when I publish it into a webtool.
Is there a way to include this dynamic text in a custom print layout web tool?
I'm assuming you are talking about 'dynamice text' elements in ArcGIS Pro.
Long story short, in order for it to work, you need to publish an arcpy based print service with a layout-template pre-populated with layers.
Pls check out the following tutorial that shows what I meant by 'layout-templates pre-populated with layers'
Pls note that tutorial was written assuming ArcMap being the publishing/authoring client app (not ArcGIS Pro). So, if you want to go with this solution from ArcGIS Pro, then pls remember you can't follow these steps literally.
Also, note that this is a heavily customized solution targeting a very specific use case - not meant as a generic print service solution. Plus, for performance reasons, we usually recommend not to have any layers in your layout templates.