Automação para formulários Google

PT-BR

Me pediram para criar um formulário inteligente, onde ele atualizasse um item em específico de acordo com o que o usuário inserisse. Como uma espécie de ID.

Através do AppsScript, criei o seguinte código abaixo para realizar isso:

function…


This content originally appeared on DEV Community and was authored by Matheus Coelho

PT-BR

Me pediram para criar um formulário inteligente, onde ele atualizasse um item em específico de acordo com o que o usuário inserisse. Como uma espécie de ID.

Através do AppsScript, criei o seguinte código abaixo para realizar isso:

function updateForms() {
    const id = "Enter your SpreadSheet ID here!";
    const sheetName = "Enter the Sheet's name of items want to be auto uploads!";

    const ss = SpreadsheetApp.openById(id);
    const sheet = ss.getSheetByName(sheetName);
    const range = sheet.getDataRange().getValues(); // i recommend you do a sheet only to set data'll be upload

    const choiceValues = [...new Set(range.map(row => row[0]).filter(value => value))];

    const form = FormApp.openById("Enter your Forms ID here!");
    const items = form.getItems();

    for (var i in items) {
      if (items[i].getTitle() == "Set here the question name of Forms!") {
        items[i].asListItem().setChoiceValues(choiceValues);
        return;
      }
    }
    Logger.log("Nothing found...");
  }

O código era para atualizar os dados que alimentariam um relatório semanal.

Encontre mais informações no repositório.

EN-US

I was asked to create a smart form that would update a specific item based on what the user entered. Like a sort of ID.

Using AppsScript, I created the following code to do this:

function updateForms() {
    const id = "Enter your SpreadSheet ID here!";
    const sheetName = "Enter the Sheet's name of items want to be auto uploads!";

    const ss = SpreadsheetApp.openById(id);
    const sheet = ss.getSheetByName(sheetName);
    const range = sheet.getDataRange().getValues(); // i recommend you do a sheet only to set data'll be upload

    const choiceValues = [...new Set(range.map(row => row[0]).filter(value => value))];

    const form = FormApp.openById("Enter your Forms ID here!");
    const items = form.getItems();

    for (var i in items) {
      if (items[i].getTitle() == "Set here the question name of Forms!") {
        items[i].asListItem().setChoiceValues(choiceValues);
        return;
      }
    }
    Logger.log("Nothing found...");
  }

The code was to update the data that would feed a weekly report.

Find more information in the repository.


This content originally appeared on DEV Community and was authored by Matheus Coelho


Print Share Comment Cite Upload Translate Updates
APA

Matheus Coelho | Sciencx (2024-07-27T04:06:37+00:00) Automação para formulários Google. Retrieved from https://www.scien.cx/2024/07/27/automacao-para-formularios-google/

MLA
" » Automação para formulários Google." Matheus Coelho | Sciencx - Saturday July 27, 2024, https://www.scien.cx/2024/07/27/automacao-para-formularios-google/
HARVARD
Matheus Coelho | Sciencx Saturday July 27, 2024 » Automação para formulários Google., viewed ,<https://www.scien.cx/2024/07/27/automacao-para-formularios-google/>
VANCOUVER
Matheus Coelho | Sciencx - » Automação para formulários Google. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/07/27/automacao-para-formularios-google/
CHICAGO
" » Automação para formulários Google." Matheus Coelho | Sciencx - Accessed . https://www.scien.cx/2024/07/27/automacao-para-formularios-google/
IEEE
" » Automação para formulários Google." Matheus Coelho | Sciencx [Online]. Available: https://www.scien.cx/2024/07/27/automacao-para-formularios-google/. [Accessed: ]
rf:citation
» Automação para formulários Google | Matheus Coelho | Sciencx | https://www.scien.cx/2024/07/27/automacao-para-formularios-google/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.