• Resolved cotrones

    (@cotrones)


    Hi Zaus,

    I have been attempting to use your plugin in order to automatically post new registrations on my Gravity Form to a spreadsheet on Google Sheets. I’m not sure if this matters, but my Form is placed in a pop up. I have been using this as a guideline: https://gravityplus.pro/gravity-forms-to-google-sheets/

    I was wondering if you have already figured out a way to accomplish this? I have installed your 3rd party integration plugin as well as your post to xml plugin. I am currently stuck as I am receiving a long error message. I can send the message to you if you would like to view it but I did not want to post it on here due to it’s length. I appreciate you taking your time to read this and hope to hear from you soon!

    Thanks in advance,
    Tom

    https://wordpress.org/plugins/forms-3rdparty-integration/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author zaus

    (@zaus)

    That seems excessive. Pretty sure someone else asked the same question on the forum already, can’t remember where.

    If you make a Google Form, it will save the results to a Google Spreadsheet automatically. Publish the form, then look at the page source to get the submission URL (will be your endpoint) and the field names (will be your destination mappings).

    Should be pretty straightforward, only needs the base plugin, not even the Xpost add-on.

    Thread Starter cotrones

    (@cotrones)

    Thanks for the reply. I’m new to this if you couldn’t already tell. I am still receiving a failure notice, I’m not sure where I’m going wrong. I will paste the email below. A few other questions:

    Do you think I am messing up the mapping?
    I already have the field names on my Google Sheet, should I delete these?
    Does this form seem correct to you or do I not even need this code?:

    function doPost(e) {
    
      if (!e) return;
    
      var sheetID = "1_pextohBKnlOyWvuD3bwypdXSX7ZqHBnf7zvFjB7jkw";  // Replace this with the Google Spreadsheet ID
      var sheetName = "Gravity Forms Test Sheet";       // Replace this with the sheet name inside the Spreadsheet
    
      var status = {};
    
      // Code based on Martin Hawksey (@mhawksey)'s snippet
    
      var lock = LockService.getScriptLock();
      lock.waitLock(30000);
    
      try {
    
        var sheet = SpreadsheetApp.openById(sheetID).getSheetByName(sheetName);
        var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0];
    
        // Add the data and time when the Gravity Form was submitted
        var column, row = [],
          input = {
            "timestamp": new Date()
          };
    
        for (var keys in e.parameter) {
          input[normalize_(keys)] = e.parameter[keys];
        }
    
        for (i in headers) {
          column = normalize_(headers[i])
          row.push(input[column] || "");
        }
    
        if (row.length) {
    
          sheet.appendRow(row);
          status = {
            result: "success",
            message: "Row added at position " + sheet.getLastRow()
          };
    
        } else {
          status = {
            result: "error",
            message: "No data was entered"
          };
        }
    
      } catch (e) {
    
        status = {
          result: "error",
          message: e.toString()
        };
    
      } finally {
    
        lock.releaseLock();
    
      }
    
      return ContentService
        .createTextOutput(JSON.stringify(status))
        .setMimeType(ContentService.MimeType.JSON);
    
    }
    
    function normalize_(str) {
      return str.replace(/[^\w]/g, "").toLowerCase();
    }

    Really sorry for the long post I just want to figure this out. I appreciate your help. Here is the failure email I received:

    There was an error when trying to integrate with the 3rd party service {Service 1} (https://script.google.com/macros/s/AKfycbyWce3ApBXG2CwobvA4e4hAYoTDhzwDdgsRqc_SIbP89klDCDox/exec).

    **FORM**
    Title: SIGNUP NOW
    Intended Recipient: –na–
    Source: http://hotjobing.com/browse-jobs/?search_keywords&search_location&search_category=22

    **SUBMISSION**
    Array
    (
    [timeout] => 10
    [body] => Array
    (
    [First Name] => Tom
    [Last Name] => Cotroneo
    [Email Address] => tomcotroneo@gmail.com
    [Phone Number] => (973) 303-0477
    [Job Category] => E-Commerce
    [Edu. Level] => Completed HS or Ged
    [Interested In] => Yes
    )

    )

    **RAW RESPONSE**
    Array
    (
    [headers] => Array
    (
    [content-type] => text/html; charset=UTF-8
    [content-length] => 1555
    [date] => Wed, 27 Jul 2016 18:52:16 GMT
    )

    [body] => <!DOCTYPE html>
    <html lang=en>
    <meta charset=utf-8>
    <meta name=viewport content=”initial-scale=1, minimum-scale=1, width=device-width”>
    <title>Error 400 (Bad Request)!!1</title>
    <style>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
    </style>
    <span id=logo aria-label=Google></span>
    <p><b>400.</b> <ins>That’s an error.</ins>
    <p>Your client has issued a malformed or illegal request. <ins>That’s all we know.</ins>

    [response] => Array
    (
    [code] => 400
    [message] => Bad Request
    )

    [cookies] => Array
    (
    )

    [filename] =>
    [safe_message] => physical request failure
    )

    Thread Starter cotrones

    (@cotrones)

    Hey Zaus, I was wondering what should be in my Google Form in order for it to integrate properly?

    Thread Starter cotrones

    (@cotrones)

    Do you happen to have an example of a Google Form submission url? Or could you point me in the right direction in the page source?

    Thanks in advance!

    Plugin Author zaus

    (@zaus)

    Publish a Google Form, then look at the page source (ctrl+u, usually, or right-click), then look for the ‘form’ tag and copy the action attribute. If it doesn’t have one then use the page URL.

    Plugin Author zaus

    (@zaus)

    I just confirmed this works with a new Google Doc. Here’s a javascript snippet to help extract the input tags. Paste in the Developer Console (Chrome: F12, ESC)

    (function($) {
        var $form = document.querySelector('form');
        var args = {
            action: $form.action,
            inputs: []
        };
    
        var $inputs = $form.querySelectorAll('input');
        $inputs.forEach(function(v,k) {
            var label = v.getAttribute('aria-label') || v.getAttribute('title');
            if(!label && v.id) {
                label = $form.querySelector('label[for='+v.id+']').innerText;
            }
    
            var input = {name: v.name};
            if(v.id) input.id = v.id;
            if(label) input.label = label;
    
            args.inputs.push(input);
            // console.log('input', k, v);
        })
    
        console.log(args);
        console.table(args.inputs);
    
    })();
    • This reply was modified 9 years, 8 months ago by zaus. Reason: clarification
Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Gravity Forms to Goole Sheets’ is closed to new replies.