Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

228
Views
Form Field Does Not Complete By URL In Iframe or Google Site - but does as independent web app

I am trying to complete a form created in google app script web app via URL with the intention to display the field but be inactive and a UUID for form submit.

In web app testing the form is completed by URL eg: https://script.google.com/macros/s/AKfycbwam4eZHPrs2ooVQLzJZgMcFb9gfXC2OPSq8f7Xkp9z/dev?fn=bob filling "bob" into field "fn".

However to remove googles "This application was created by another user, not by Google.Terms of Service" we put the web app in and iframe or link in google sites. This throws a spanner in the works.

Any advise will be much appreciated


    function doGet() {
      return HtmlService.createTemplateFromFile("page").evaluate().setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
    }
    
    
    function userClicked(userInfo){
     
      const url = "https://docs.google.com/spreadsheets/d/1-7D4bXhm1Yx0ekRUmrwr8fTsdQ0dLtMI4gYG-THPUdk/edit#gid=0";
      const ss = SpreadsheetApp.openByUrl(url);
      const ws = ss.getSheetByName("data");
     
     ws.appendRow([userInfo.firstName,userInfo.lastName,userInfo.app,new Date()])
    
     // Logger.log(name + " Clicked The Button");
    
    }
    
    function include(filename){
      return HtmlService.createHtmlOutputFromFile(filename).getContent();
    
    }
    <script>

        document.addEventListener('DOMContentLoaded', function() {
          var elems = document.querySelectorAll('select');
          var instances = M.FormSelect.init(elems);
        });

      document.getElementById("btn").addEventListener("click",doStuff);

      function doStuff(){

        const userInfo = {};

        userInfo.firstName = document.getElementById("fn").value;
        userInfo.lastName = document.getElementById("ln").value;
        userInfo.app = document.getElementById("app").value;

        google.script.run.userClicked(userInfo);

        document.getElementById("fn").value = "";
        document.getElementById("ln").value = "";

        var myApp = document.getElementById("app");
        myApp.selectedIndex = 0;
        M.FormSelect.init(myApp);

      }


    </script>

      <script>
        google.script.url.getLocation(function(location){

          document.getElementById('fn').value = location.parameters.fn[0]
          document.getElementById('ln').value = location.parameters.ln[0]
        })

        </script>
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Unfortunately there is no way to pass a query string parameter into a Google Apps Script web app embedded in Google Sites but this might be done by using client-side JavaScript on a "regular" web page.

Note: Use the /exec URL, not the /dev one.

<body onload="loadIframe();">
   
    <div id="content">
        <iframe width="100%" height="100%" frameborder="0"></iframe>
    </div>
    <script>
    function loadIframe(){
        const url = "put_here_your_web_app_url" + window.location.search;
        document.querySelector('iframe').src = url;
    }
    </script>
</body>

Related

  • Google Apps Script Gadget URL parameters are ignored when embedded in a Google Site
  • google site: pass parameters to embedded script
  • Google Apps script get Parent URL to iFrame in Javascript
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!