Произошла ошибка скриптовая функция не найдена

I am working to link an image in my Google Sheet document to a specific cell in another tab. I’m doing this by building a simple function that will do this. However, when I assign the function and then click on the image, I then get the error «Script function «test» could not be found». When I run the function in the script manager interface, it works fine. It’s when I try to actually use it in the sheet with the image.

Function Script:

function test()
{
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("TX Marketing Data");
  sheet.setActiveRange(sheet.getRange("A91"));
};

enter image description here

Steps to recreate:
1) Create image
2) Go to image, right click, go to drop down and select «Assign Script»
3) Enter «test» as the assign script

Rubén's user avatar

Rubén

34.8k9 gold badges70 silver badges166 bronze badges

asked May 19, 2016 at 21:32

davecut85's user avatar

5

Had a similar problem and just solved it.

When assigning a script function to a button make sure to call the specific function name(i.e. «getWeatherData») and not the App Script name (i.e. «WeatherAPI»).

answered Feb 12, 2021 at 14:51

Aaron Alex Vargas's user avatar

2

Remove «;» at the end of your function (after }).

answered May 20, 2016 at 6:25

Amir's user avatar

AmirAmir

1,6653 gold badges23 silver badges42 bronze badges

0

Another thing that can happen is that you have a library that has the same name as the function. For example you have imported a library that to refer to «test» in your code. If you name your function

function test(){
   your code
}

Then you will get the same error that you got.
visual example of library with same name of a function

answered Aug 19, 2021 at 19:44

Mathieu's user avatar

Try reloading the page.

Sounds like a simple ‘turn it off and on again’ fix but after having the same issue and trying to save a new version, renaming the function, creating new function etc. a page reload was all it took!

answered Mar 27, 2018 at 13:39

Ben Kammerling's user avatar

I had exactly the same problem. Eventually I found the problem when I looked at the script Function name, which should be Function followed by the name you gave the script when it was created. when creating file names sometimes you are not able to use special characters which is what I had done. Once I gave it a name that had allowable characters there was no problem. In programming when you call a function that does not match the name given to the function or procedure you will end up getting the error function not found.

answered Dec 14, 2020 at 4:25

Travis's user avatar

I had the exact same issue, when I used submitdata , after I changed it to submitData it said it submitdata was deleted. so i put it back to original form and bam!! fixed.

answered Aug 6, 2021 at 10:39

Joe's user avatar

Same issue, but much dumber reason for me.

So, here is my answer: Make sure to hit the «Save» button in Apps Script.

I was so used to all the other google apps automatically saving/syncing I didn’t realize that I actually had to hit «Save» on the scripts. I caught it when I noticed the function I was trying to run wasn’t appearing in the list of functions to run in Apps Script. Once it hit save, the name of the function appeared in the list AND clicking my button ran it successfully from the sheet.

answered Jan 20, 2022 at 16:04

Trashman's user avatar

TrashmanTrashman

1,42418 silver badges27 bronze badges

You should call your function name, not the script itself. If your function is called myFunction() you should write myFunction. And be careful to rename your function to something that isn’t already in your library

answered Jan 28, 2022 at 11:53

FranciscoSilva's user avatar

1

Ran into the same issue but solved it by renaming it with a prefix, executing it in Sheets and then renaming it back without the prefix.

function calculateSomething() {
  return 10;
}

To

function prefixCalculateSomething() {
  return 10;
}

Update the Sheet with the new name, it should work now.
Now rename it back.

function calculateSomething() {
  return 10;
}

Update the Sheet with the original name, and it should still work.
Maybe a refresh would’ve worked as well but that’s not how I solved it.

answered May 7, 2022 at 2:24

Nate-Wilkins's user avatar

Nate-WilkinsNate-Wilkins

5,3644 gold badges46 silver badges61 bronze badges

I found that I had renamed my Macro, removed spaces, and added Uppercase, but the name in the script function statement didn’t match what I could swear I had set in
«Extensions->Macros->Manage Macros».
When I changed the syntax of the image to match the function statement, including case, it worked fine.
(I don’t know if spaces work in the name, I originally had them, but remembered that I’ve had trouble with them in Excel. I removed them at the same time as doing other changes, so I didn’t confirm if it was an issue.)

answered Oct 30, 2022 at 22:46

Plankton's user avatar

Having had the same issue when clicking a button, what fixed the problem for me was removing spaces from the macro name that was being assigned, despite the fact that it worked fine with spaces when using the hot keys assigned to it.

answered Mar 30 at 13:23

BSmarker's user avatar

I had the same issue. I had left in the brackets (parenthesis) when assigning the script to the button. Took those out and it worked fine.

answered Jun 7 at 11:00

Kevan Holden's user avatar

Я работаю, чтобы связать изображение в документе Google Sheet с конкретной ячейкой на другой вкладке. Я делаю это, создавая простую функцию, которая сделает это. Однако, когда я назначаю функцию и затем нажимаю на изображение, я получаю сообщение об ошибке «Script функция» test «не найдена». Когда я запускаю функцию в интерфейсе менеджера script, он отлично работает. Это когда я пытаюсь на самом деле использовать его в листе с изображением.

Функция Script:

function test()
{
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("TX Marketing Data");
sheet.setActiveRange(sheet.getRange("A91"));
};

введите описание изображения здесь

Шаги по воссозданию:

1) Создать изображение

2) Перейдите к изображению, щелкните правой кнопкой мыши, перейдите в раскрывающийся список и выберите «Назначить Script»

3) Введите «test» в качестве назначения script

#google-apps-script

Вопрос:

Мне удалось собрать воедино функцию, приведенную ниже. Однако теперь это не позволяет мне назначить скрипт кнопке. Он продолжает выдавать мне эту ошибку «Не удалось найти обновленные данные функции скрипта». Имя файла и имя функции являются «обновленными данными». Функция теперь работает идеально, поэтому должны быть какие-либо ошибки, которые помешали бы ей найти скрипт.

 function updateData() {
  var app = SpreadsheetApp;
  var ss = app.openById('1MNYUjdt0OCeOZyoNVAZbIRoM7kevG12njF5i57FyR5A');
  var db = ss.getSheetByName('Dashboard');
  var inputR  = db.getRange('B54:L54');
  var inputV = inputR.getValues();
  var data = db.getRange('B59:L1051').getValues();
    for (var i = 0; i<data.length; i  ) {
    if (!data[i].join("")) break;
  }
  var emptyRow = i   1;
  db.getRange(58   emptyRow, 2, 1, 11).setValues(inputV);
  inputR.clearContent();
  Logger.log(emptyRow);
  Logger.log(inputV);
}
 

Обновление — 10/2/2021

Проблема:
Я выяснил, в чем проблема. Это немного странно. Я заметил, что, если я вошел в несколько учетных записей Gmail в рамках одного сеанса Google Chrome, когда я нажимаю «Инструменты» > «Редактор сценариев» в электронной таблице, он попытается перенести меня на страницу приложения Google script для учетной записи пользователя по умолчанию(это первая учетная запись, в которую вы вошли в рамках сеанса). Поскольку я создал свою электронную таблицу в учетной записи Gmail, отличной от моей учетной записи по умолчанию, она выдаст ошибку разрешения. Что я сделал, так это зашел на домашнюю страницу приложения Google script и создал новый проект на странице профиля приложения Google script. Несмотря на то, что код будет работать, когда вы запустите его в приложении-скрипте, кнопка в Google таблицах не сможет найти нужную функцию.

Решение:
Мне пришлось открыть электронную таблицу в окне инкогнито, войти только в ту учетную запись, в которой я создал электронную таблицу, и перейти в инструменты>редактор сценариев. В новом проекте, который он создал, я вставил код из функции исходного сценария. Я обновил название функции и назначил ее кнопке. БАМ! Наконец-то решено!

Я заметил, что мой список проектов в приложении Google script выглядел так, что значок ссылки для нового проекта (см. Рисунок (желтая подсветка)) был значком Google Листов (то есть он был связан), а в старом проекте (зеленая подсветка) был только значок сценария.

Изображение моей страницы проектов Google Script

Ответ №1:

Понимание основной проблемы:
я обнаружил проблему. Это немного странно. Я заметил, что, если я вошел в несколько учетных записей Gmail в рамках одного сеанса Google Chrome, когда я нажимаю «Инструменты» > «Редактор сценариев» в электронной таблице, он попытается перенести меня на страницу приложения Google script для учетной записи пользователя по умолчанию(это первая учетная запись, в которую вы вошли в рамках сеанса). Поскольку я создал свою электронную таблицу в учетной записи Gmail, отличной от моей учетной записи по умолчанию, она выдаст ошибку разрешения. Что я сделал, так это зашел на домашнюю страницу приложения Google script и создал новый проект на странице профиля приложения Google script. Несмотря на то, что код будет работать, когда вы запустите его в приложении-скрипте, кнопка в Google таблицах не сможет найти нужную функцию.

Решение:
Мне пришлось открыть электронную таблицу в окне инкогнито, войти только в ту учетную запись, в которой я создал электронную таблицу, и перейти в инструменты>редактор сценариев. В новом проекте, который он создал, я вставил код из функции исходного сценария. Я обновил название функции и назначил ее кнопке. БАМ! Наконец-то решено!

Я заметил, что мой список проектов в приложении Google script выглядел так, что значок ссылки для нового проекта (см. Рисунок (желтая подсветка)) был значком Google Листов (то есть он был связан), а в старом проекте (зеленая подсветка) был только значок сценария.

Изображение моей страницы проектов Google Script

Google Docs Editors Help

Sign in

Google Help

  • Help Center
  • Community
  • Google Docs Editors
  • Privacy Policy
  • Terms of Service
  • Submit feedback

Send feedback on…

This help content & information

General Help Center experience

  • Help Center
  • Community

Google Docs Editors

As per my previous post related to ‘How to create a simple Hello World standalone HTML/Javascript page with Example in Google App Script’. I have explained about Code.gs file in Step 4. When you created the new project first time the Code.gs file by default created in editor in which we need to create a method function doGet(e). 

See example below:

function doGet(e) {
  return HtmlService
    .createHtmlOutputFromFile(‘helloworld.html’)//This is html file we want to render
    .setTitle(«Hello World Example»);//We can set title from here
}

We need to add doGet(e) function in Code.gs to publish project as WebApp. This function uses HTMLService to return HTML Output of helloworld.html file that we created earlier post ‘How to create a simple Hello World standalone HTML/Javascript page with Example in Google App Script’.

If you missed to add this function doGet(e) in Code.gs file then it generally throws this error message «Script function not found: doGet».

For more detail please refer google developers doc: https://developers.google.com/apps-script/guides/web

I hope, it must be helpful & please share your feedback or queries in comments box.

Понравилась статья? Поделить с друзьями:

Интересное по теме:

  • Произошла ошибка установки 400 4game
  • Произошла ошибка синхронизации пожалуйста попробуйте еще раз
  • Произошла ошибка сети что делать
  • Произошла ошибка установки 200 black desert 4game
  • Произошла ошибка сети телевизор самсунг ютуб

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии