Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

319
Visualizações
I am writing a script to copy a file Url to an Html Output. The issue I am having is the Url code has the text '?usp=drivesdk' added to the Url

My code to get the Url (from a new worksheet that has been copied)

DriveApp.getFileById(sheet.getId()).makeCopy(nom,destFolder).getUrl();

var htmlOutput = HtmlService.createHtmlOutput('<a href="https://docs.google.com/spreadsheets/d' +  '/" target="_blank">' + fileUrl + '</a>')
    .setWidth(350).setHeight(50);

SpreadsheetApp.getUi().showModalDialog(htmlOutput,'Flowcalculator');

The Html shows the correct Url for the new file except it has an ending ....../edit?usp=drivesdk.
Do I need to write a 'format' function to delete the ?usp=drivesdk. or change the suffix to 'share' (I want the user to be able to open the file from the ModalDialog by clicking on the Url

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I think that in your situation, even when https://docs.google.com/spreadsheets/d/{spreadsheetId}/edit?usp=drivesdk is used as the hyperlink for opening the Spreadsheet, the link can be used.

I thought that in your script, '<a href="https://docs.google.com/spreadsheets/d' + '/" target="_blank">' + fileUrl + '</a>' is required to be modified. In this case, the URL is https://docs.google.com/spreadsheets/d/. This cannot be used.

If you want to open the copied Spreadsheet by clicking the link on the dialog, how about the following modification?

Modified script:

var fileUrl = DriveApp.getFileById(sheet.getId()).makeCopy(nom, destFolder).getUrl();
var htmlOutput = HtmlService.createHtmlOutput(`<a href="${fileUrl}" target="_blank">${fileUrl}</a>`).setWidth(350).setHeight(50);
SpreadsheetApp.getUi().showModalDialog(htmlOutput, 'Flowcalculator');
  • In this case, please declare the variables of sheet, nom, and destFolder.

  • If you want to use https://docs.google.com/spreadsheets/d/{spreadsheetId}/edit?usp=sharing instead of https://docs.google.com/spreadsheets/d/{spreadsheetId}/edit?usp=drivesdk, please modify as follows.

    • From

        var fileUrl = DriveApp.getFileById(sheet.getId()).makeCopy(nom, destFolder).getUrl();
      
    • To

        var fileUrl = DriveApp.getFileById(sheet.getId()).makeCopy(nom, destFolder).getUrl().replace("drivesdk", "sharing");
      
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda