Home > Net >  How to extract URL of created html form using google app script
How to extract URL of created html form using google app script

Time:02-28

I'm using google app script to build something like a form that helps me with automation.

here's the code for building my form

<div >
    <div >
      <div >
        <input  placeholder="Enter video link" id="vid" type="text"/>
      </div>

  <div >
    <select  id="vcategory">
      <option value='' disabled selected hidden>Select video category</option>
      <option value='Film & Animation'>Film & Animation</option>
      <option value='Autos & Vehicles'>Autos & Vehicles</option>
      <option value='Pets & Animals'>Pets & Animals</option>
      <option value='Sports'>Sports</option>
      <option value='Travel & Events'>Travel & Events</option>
      <option value='Gaming'>Gaming</option>
      <option value='People & Blogs'>People & Blogs</option>
      <option value='Comedy'>Comedy</option>
      <option value='Entertainment'>Entertainment</option>
      <option value='News & Politics'>News & Politics</option>
      <option value='How to & Style'>How to & Style</option>
      <option value='Education'>Education</option>
      <option value='Science & Technology'>Science & Technology</option>
      <option value='Nonprofits & Activism'>Nonprofits & Activism</option>
    </select>
  </div>
</div>

<div >
  <button  onclick="addRow()">Add</button>
</div>

<div >
  <div  id="ok" style="display:none">
    <h3>Thanks</h3>
    <p>This is a new one</p>
  </div>

  <div  id="warn" style="display:none">
    <h3>Duplicate!</h3>
    <p>The video ID or Name is already on the list</p>
  </div>

  <div  id="missing" style="display:none">
    <h3>Input missing!</h3>
    <p>Viedo link or Category is missing</p>
  </div>
</div>
</div>

At this point everything works fine and I can see my Form when I deploy.

I get the forms values through a function that send these values to doGet() function and I add them to the spreadsheet cells.

What I want to do, is when I do run this script .. it sends me to a new tab containing the created form, as this form is not created as a submenu in the spreadsheet, it's completely in another page/tab .. I want to get this page/tab url as I need to access it's parameters in the future.

I tried to use google.script.url as in the documentation but it sent me empty object,

I tried to use window.location.href, it sent me a weird URL that I couldn't recognize and it's not the one for the created tab.

Any help would be appreciated :)

CodePudding user response:

ScriptApp.getService().getUrl()

  • Related