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

158
Visualizações
Wrapper around importdata() in Google Sheets

I am trying to write a wrapper around Google Sheets' importdata() in code.gs:

100 
101  function cryptofinance(token) {
102     var currentCell = SpreadsheetApp.getCurrentCell();
103     currentCell.setValue('=importdata("https://cryptoprices.cc/"+ token)');
104  }
105
106 ...

The idea is to call the function from any sheet in the spreadsheet to get the price of any crypto currency token:

    |          A
+---+-------------------------+
| 1 |  =cryptofinance("aion") |
+---+-------------------------+

I get an error though when I try this:

    |          A
+---+-------------------------+
| 1 |  #ERROR                 |
+---+-------------------------+

#ERROR Exception: You do not have permission to perform that action. (line 102).

Why is this happening and how can I solve it?

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

0

Custom functions can be used to return values, period.

Custom function can't be used to execute any method that require authorization to run and can't modify attributes of the cell / range that contain the formula using the custom function. Ref. https://developers.google.com/apps-script/guides/sheets/functions

You might use a UrlFetchApp service in a custom function to call external services but you still have the restrictions of custom function i.e. 30 seconds execution time limit.

Related

  • Function from script editor works fine but not from sheets custom function
about 4 years ago · Juan Pablo Isaza Relatório

0

Try this:

function cryptofinance(token = "AION") {
 //Logger.log(UrlFetchApp.fetch(`https://cryptoprices.cc/${token}/`));
 return UrlFetchApp.fetch(`https://cryptoprices.cc/${token}/`).getContentText();
}
about 4 years ago · Juan Pablo Isaza Relatório

0

Some permissions are assumed by Apps Scripts when running functions but in some instances you need to update your appsscripts.json with the correct OAuth permissions manually to give permission to access data.

To show your appsscripts.json, navigate to your project settings and toggle the option "Show 'appsscript.json' manifest file in editor". This should reveal it in the sidebar in Apps Scripts.

Once in the appsscript.json, add

"oauthScopes": [
    "https://www.googleapis.com/auth/spreadsheets",
 ]

You can read more about it here

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