<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Matheus Coelho</title>
    <description>The latest articles on DEV Community by Matheus Coelho (@mirangod).</description>
    <link>https://dev.to/mirangod</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1808966%2F3d34b7b4-6ffe-4ddd-b914-5b2a53e11cd6.jpg</url>
      <title>DEV Community: Matheus Coelho</title>
      <link>https://dev.to/mirangod</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mirangod"/>
    <language>en</language>
    <item>
      <title>Automação para formulários Google</title>
      <dc:creator>Matheus Coelho</dc:creator>
      <pubDate>Sat, 27 Jul 2024 04:06:37 +0000</pubDate>
      <link>https://dev.to/mirangod/automacao-para-formularios-google-3jie</link>
      <guid>https://dev.to/mirangod/automacao-para-formularios-google-3jie</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;PT-BR&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;Através do AppsScript, criei o seguinte código abaixo para realizar isso:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;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 =&amp;gt; row[0]).filter(value =&amp;gt; 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...");
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;O código era para atualizar os dados que alimentariam um relatório semanal.&lt;/p&gt;

&lt;p&gt;Encontre mais informações no &lt;a href="https://github.com/ativadev/update-google-forms" rel="noopener noreferrer"&gt;repositório&lt;/a&gt;.&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;EN-US&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;Using AppsScript, I created the following code to do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;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 =&amp;gt; row[0]).filter(value =&amp;gt; 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...");
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code was to update the data that would feed a weekly report.&lt;/p&gt;

&lt;p&gt;Find more information in the &lt;a href="https://github.com/ativadev/update-google-forms" rel="noopener noreferrer"&gt;repository&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>google</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>form</category>
    </item>
  </channel>
</rss>
