How can we get a link to a doc?

We are needing to get the link of a document uploaded in appsheet.

What is saved in the table is not a link but a path to the document in drive.

How can we get a link?

@Phil @Steve

Short answer: No.

But you could get around with some workarounds, like the one shown on the docs
Display images and documents - AppSheet Help

1 Like

or you can write a google script that will monitor the table, take the file name from it and return a link to the file located on the google drive

var File =DriveApp.getFilesByName(Bild_name).next()
var DownloadUrl = File.getDownloadUrl()

drive.google.com/uc?id=1E3ZQl-BYu-5gdIPIyinS39YXpZr8rp7B&export=download

This worked very well!!

Now the twist more… how we could generate a link for a file that I create by means of a bot?

Where you need that link?

1 Like

We have a bot that generates a document. And we need to send that document to an external application (via JSON). For this we need the link.

When we load it from the PC there is no problem, the previous solution works, but if we generate it from the bot… well we don’t know

as well as a script. you have a place a file is created, there is a file name. the script will do the rest

1 Like

And… Is it possible via appsheet? Whitout scrips…

I think no. the script is not hard

How? We never do it

I went fishing, in a couple of days there will be a computer, I will write a script. If no one does it first

function searchFiles(title) {

var files = DriveApp.searchFiles(
‘title contains "’+title+‘"’ );
while (files.hasNext()) {
var file = files.next();
var parents = file.getParents();
var folder = parents.next()

var fileName = file.getName()
var download_Link = file.getDownloadUrl()
Logger.log( download_Link+" / " + fileName+" / ");
return download_Link

}
}

1 Like

this script can find a link to a file. title you can transfer from Appsheet. and return back download_link. More information is on this forum.

1 Like

Thanks koma!

How do we use the script in Drive?

https://script.google.com/home/start?pli=1

create a new script and paste the code into it. then connect it to the bot in your app. and receive a Link as a return value. Yesterday there was an article on this site on how to do it.

https://www.googlecloudcommunity.com/gc/Tips-Tricks/Generating-Sequential-Numbering-Using-App-Script-Tasks/m-p/451776#M6863

You need to pass only the file name to the script, and get back the link

1 Like

Hi Koma,

The bot looks like this:

The first step generates the document and the second step is the script and the third is the json that sends the document to the web page for its digital signature.

The point is that the link we have to send is the access link, for example:

https://www.appsheet.com/template/gettablefileurl?appName=Testing-100015&tableName=ABM&fileName=ABM_Files_%2F9c7f5394.Adjunto_Alta.193820.pdf&appVersion=1.000008&signature=85ff62d6d130f712af7357808a3e7744d3bf95191e0f376fc053ab5e03ea30687eb6786bd472799209334414c02f615e

What we did was generate a doc with the following name:

And in the script we put the same statement:

LXARGENTINA_S_A_2-1660054836862.png

The JSON is:

When running it sends everything fine, but the third party program can’t open it.

We think it’s because the json doesn’t recognize the download link, but it has to be like the one in the example… rather access…

Try to replace in the script:

file.getDownloadUrl()

on the

file.getUrl()

I don’t know how else to help

And how do we save the generated doc in a column?

Because in this case we can use the anterior solution…

function searchFiles(title,source_Id,sheetName,rownum,columnNum) {

var table_id = source_Id
var sheet = sheetName
var row = rownum
var column = columnNum
var sh = SpreadsheetApp.openById(table_id).getSheetByName(sheet)
var files = DriveApp.searchFiles(
‘title contains "’+title+‘"’ );
while (files.hasNext()) {
var file = files.next();
var parents = file.getParents();
var folder = parents.next()

var fileName = file.getName()
var download_Link = file.getDownloadUrl()
sh.getRange(row,column).setValue(download_Link)
Logger.log( download_Link+" / " + fileName+" / ");
return download_Link

}
}

[_THISROW].