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…