Blank webpage when trying to display a PDF when weblink clicked

Hi! Iā€™m trying to use this tutorial

but to display a PDF that is attached to a file field on a web page when a link is clicked on a e-mail. But when I do this:

var file_url = relat_rios___consultor_field_file_url_1_formatted_value

console.log(file_url)

if (file_url && file_url.startsWith('http')) {
var_html_pdf = '<iframe src=${' + file_url + '} width="100%" height="600px"></iframe>'
} else {
'Not available.'
}

The console.log is returning nothing, i.e. it seems like my field is empty but its notā€¦ I donā€™t know if Iā€™m doing something wrong but I found no situation like this in tape community.

What Iā€™m doing is trying to return the variable html_pdf on the ā€œdisplay on a web pageā€ action on my workflowā€¦ But the webpage is blank.

Could anyone help me?

hi @agnes.farias

this:

const file_url = document_field_files_file_url;
console.log(file_url);

let dis;

if (file_url && file_url.startsWith('http')) {
  dis = `<iframe src="${file_url}" width="100%" height="600px"></iframe>`;
} else {
  dis = 'Not available.';
}

var_pdfd = dis;

gets me the url, are you putting the correct field into your file_url variable? (I expect you are but I canā€™t see anything else)

However I am not sure it will do what you want anyway at least I failed to manage it either with the iFrame or:

const file_url = document_field_files_file_url;
console.log(file_url);

let dis;

if (file_url && file_url.startsWith('http')) {
  dis = `<object data=file_url type="application/pdf" width="100%" height="500px">`;
} else {
  dis = 'Not available.';
}

var_pdfd = dis;

Both ways just want to download the pdf rather than display it so not sure if the automation URL is slightly different or the ā€˜display on a web pageā€™ handles it in a different way.

Hi Jason, thanks for the help.

In this case, Iā€™m storing the file URL in a variable called ā€œFile URLā€ and Iā€™m trying to use it to display the PDF on a web page. But even when Iā€™m directly referring to the file URL itā€™s returning a empty value (although itā€™s notā€¦ the PDF is actually there).

Hi yep that is what I have done in my example and it works however if you look at the first line of your code it looks a little off:

var file_url = relat_rios___consultor_field_file_url_1_formatted_value

console.log(file_url)

I would expect the field that you are adding to end in url not formatted value

Yep! Itā€™s because Iā€™m using a multiple line field to store the URL, but it doesnā€™t work.
Even when I mention directly the file url, doesnā€™t work:

Return:
image

@agnes.farias thanks for sharing your use case.

We discourage using a multi line text field to store a URL. Would it be possible to use a single line text field or a link field to store the URL as an alternative?

Could you share a quick video or a couple of screenshots that show your workflow and describe in detail what you are trying to achieve?

Hi! It seems like my URL is too big for a single line text field. When I try to store it on a single line it says ā€œInvalid single text value [ā€¦] Max. length is 500ā€, thatā€™s why Iā€™m using multiple line text field as an alternative.

So, Iā€™m sending an e-mail with a table containing summarized information about employees of a company to the person in charge. The last column of the table contains a button that says ā€œDetailsā€ which should open a new window that should show the PDF with the wage report by employee.
So I have a simple workflow for when the weblink is clicked that should just run the script and display it on the web page:

This is the content of the e-mail received by the person in charge of the company:


(Employee | Reported hours | Payment Amount | Action)

And this is the PDF with the wage report, it contains a lot of detailed information about the employee like projects and taxesā€¦


I hope that makes sense.

I donā€™t understand why when I mention directly the file url on the script it doesnā€™t show any value on the consoleā€¦