title: Apps Script : write value in widget from server side
body: <p>i would like to create a modal in Apps Script where the user needs to type a number in an input and, when he clicks in &quot;search&quot; button, the text in reference to this number is write in other input.</p>
  <p>This is my script (server side) :</p>
  <pre><code> function include(filename){
     return HtmlService.createHtmlOutputFromFile(filename).getContent();
   }
  
   function ajoutLigne() {
     const classeur = SpreadsheetApp.getActiveSpreadsheet();
     const feuille = classeur.getActiveSheet();
     var widget; 
     widget = HtmlService.createTemplateFromFile(&quot;widget.html&quot;).evaluate();
     ui.showModalDialog(widget, &quot;Ajout d'une nouvelle ligne&quot;);
     widget.setWidth(600);
     widget.setHeight(600);
     }
  
   function getLibelle(codeArticle){
     const classeur = SpreadsheetApp.getActiveSpreadsheet();
     const feuille = classeur.getSheetByName(&quot;BASE ARTICLE&quot;);
     var lastRow = feuille.getLastRow();
     var tDonnees = feuille.getRange(&quot;B2:C&quot;+lastRow).getValues();
     var nbDonnees = tDonnees.filter(String).length;
     var result = &quot;&quot;;
     for (let i = 0; i &lt; nbDonnees; i ++){
       if(tDonnees[i][0] == codeArticle){
         result =  tDonnees[i][1];
       }
     }
     return result;
   }
  </code></pre>
  <p>This is my HTML's widget page :</p>
  <pre><code>&lt;!DOCTYPE html&gt;
   &lt;html&gt;
     &lt;head&gt;
       &lt;base target=&quot;_top&quot;&gt;    
       &lt;?!= include('JavaScript'); ?&gt;
     &lt;/head&gt;
     &lt;body&gt;
       &lt;p&gt;Quel code article souhaitez-vous ajouter ?&lt;/p&gt;&lt;input type=&quot;text&quot; id=&quot;codeArticle&quot;/&gt;
        
       &lt;input type=&quot;button&quot; class=&quot;button&quot; value=&quot;Recherche&quot; onclick=&quot;rechercheLibelle();&quot;&gt;
  
       &lt;p&gt; Libellé correspondant : &lt;/p&gt;
       &lt;p id=&quot;libelle&quot;&gt;&lt;/p&gt;
  
     &lt;/body&gt;
   &lt;/html&gt;
  </code></pre>
  <p>And this is my JavaScript's HTML page :</p>
  <pre><code>&lt;script&gt;
     function rechercheLibelle(){
        var codeArticle = document.getElementById(&quot;codeArticle&quot;).value;
        var test = google.script.run.getLibelle(codeArticle);
        console.log(test);
        document.getElementById(&quot;libelle&quot;).innerHTML = test;    
     }
  &lt;/script&gt;
  </code></pre>
  <p>When i launch in other function getLibelle with a correct value, it's work perfectly. But when i launch rechercheLibelle in the Javascript's HMTL page, i've &quot;undefined&quot; in value for test's variable result.</p>
  <p>Anyone can help me with that please. I think the problem comes to &quot;google.script.run.getLibelle(codeArticle)&quot; but i don't know how to translate the result from server side to my widget's html page. Thank you for advance to your help</p>