Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

321
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda