TeamDesk Knowledge Base & Support

   Home      FAQ      Forum      Idea Exchange      Ask a Question      My Stuff      Help   
Render html
We have an api action which pulls a report formatted as html into a teamdesk field. so the field contents are an entire web page with the header tags, body tags etc. (mostly it consists of tables).
I would like to be able to put this content into a word doc that my users can download, and be able to see the content rendered (eg show the table instead of all the tags like <table>, <td> , <tr>).

i thought i might be able to do this by putting the content into a formula XHTML field but that didn't seem to do it.

Has anyone done something like this or have a suggestion for how it could be done?
(it would definitely be worth it to us to invest in creating a custom script or something to do it, if it's possible at all.)

thanks in advance for any suggestions

Kathryn Whitenton
Date Created
2/6/2020 2:39:09 PM
Date Updated
2/14/2020 2:48:06 AM
basenine 2/6/2020 3:03:22 PM
Hello Kathryn

Have you tried using the browser inbuilt print to see how that renders?

If that doesn’t/hasn’t work(ed), I’d be happy to have a quick look at it free of charge
for you. It seems like a puzzle/challenge right up my alley!
I won’t need access to your application, just a sample of the webpage
Best regards,
cooper collier  2/6/2020 3:03:32 PM
You will need to make a separate column for each part you wish to have in the word document.
Then parse the content out of the imported html.

It will only work if the HTML structure does not change.

This is not really a good job for a database,

calvin peters 2/6/2020 3:08:09 PM
You might find what you are looking for here.

<More data>
<target text>text</target text>
</More data>

So your 'text' in the above would parse out like
Response("Data/More data/target data")

The syntax for your Response() is 'Response( (Text x), (Text x, Type) )
The help manual is here:
Just look up Response()

There's also more help in referencing HTML <tag>s at W3Schools online.
It helped me figure out how to 'code' those HTML reference lines and get the data with less typing.

The "text" is parsed out of the html tags '<tag>...</tag>' using " Response() inside your Call URL where the API is triggered.

Parse it out into a table in your db (even into a new table if needed) and create your document in Word or PDF format from that using a workflow trigger or a custom button.

Some of the Response() handlers can get fairly lengthy depending on your data source.
The rest is just a series of If() statements like writing the Formulas in the rest of TD.

Kathryn Whitenton 2/6/2020 3:58:59 PM
Thank you everyone for the quick responses and suggestions! in this scenario it is quite a long document and we want to be able to produce this report for about 100 different records, and the html structure can change on a daily basis. so definitely as mentioned, parsing it into columns would be not a very practical job for a database.
Brett, I am not sure exactly what you meant about using the browser in-built print function - the original page we're scraping the content from does look ok when printed.
I am hoping to figure out a way to generate a similar out put from teamdesk in order to restrict access to only our authenticated users. since it is proprietary info I would rather not post it here but Brett I'll email an example to BaseNine.

basenine 2/6/2020 6:15:51 PM
Hello Kathryn,

The 'browser print' function is inbuilt into the web browser.

ie, Safari, Firefox, Chrome, IE, Edge, Opera...etc all have a function where you can print the web page.
For Safari, Go to FILE and select Print

I did a test on the link you sent me and successfully printed the page into a pdf style document, formatted closely to the webpage. The only thing it didn't do was break the table nicely between pages.

This 'may' be the absolute simplest way to achieve your result, without programming.
I'm assuming here that the webpage link you sent me looks similar in TD(?)

Kathryn Whitenton 2/6/2020 7:16:50 PM
Oh I see what you mean Brett - we could just show users the hyperlink and let them print the web page. We do currently have that option. but are mow looking to make this content more secure. So my goal is to stop relying on these publicly visible hyperlinks, and instead scrape the content, and render it into an editable format (word doc) that my users can download through teamdesk only if they have access rights to that specific document.

basenine 2/6/2020 7:23:59 PM
I’ll have a look at the list you sent me and work from there.
I think Calvin’s approach is the correct one.
This involves splitting the content into different sections via the response() method
It will depend on what the API responses are available ie whether the tables have a specific response or whether we need to use formulas to collate/separate sections into
their own field.
I’ll have a look at the API documents and get back to you
Best regards
basenine 2/14/2020 2:48:06 AM
Hello Kathryn,

I sent a couple of emails to you this week. Just checking you received them 😀
Back to Search Results