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 

0 20 497
20 REPLIES 20

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

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?

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

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.logdownload_Link+" / " + fileName+" / ");
    return download_Link

  }
}

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.

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... 

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

Hi Koma,

The bot looks like this:

LXARGENTINA_S_A_0-1660054779456.png

 

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_...

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

LXARGENTINA_S_A_1-1660054810975.png

 

And in the script we put the same statement:

LXARGENTINA_S_A_2-1660054836862.png

 

The JSON is:

LXARGENTINA_S_A_3-1660054903648.png

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.logdownload_Link+" / " + fileName+" / ");
    return download_Link

  }
}

What we need more precisely is a link that identifies the type of file (pdf, jpeg, etc.) that is being generated

https://www.appsheet.com/template/gettablefileurl?appName=Testing-100015&tableName=ABM&fileName=ABM_...

If we could put the link of the file in a column, like when it is uploaded from the pc, we could generate the link

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()
 

 

[_THISROW].image.png

Top Labels in this Space