Automatically Submit After Successful Scan (w/ Populate Anything)

You want to auto-submit the form after you’ve scanned a QR code but you’re using Populate Anything to populate other fields based on the value scanned. You need to wait for Populate Anything to finish fetching and populating that data before the form can be submitted. This snippet handles that logic for you.

We recommend installing this snippet with our free Custom Javascript plugin:

Code

Filename: gpqr-auto-submit-on-scan-with-gppa.js

/**
 * Gravity Perks // GP QR Code // Automatically Submit After Successful Scan (w/ Populate Anything)
 * https://gravitywiz.com/documentation/gravity-forms-qr-code/
 *
 * You want to auto-submit the form after you've scanned a QR code but you're using Populate Anything
 * to populate other fields based on the value scanned. You need to wait for Populate Anything to
 * finish fetching and populating that data before the form can be submitted. This snippet handles
 * that logic for you.
 *
 * We recommend installing this snippet with our free Custom Javascript plugin:
 * https://gravitywiz.com/gravity-forms-code-chest/
 */
gform.addAction( 'gpqr_on_scan_success', function( decodedText, decodedResult, gpqrObj ) {
	$( document ).off( 'gppa_updated_batch_fields.gpqr' );
	$( document ).on( 'gppa_updated_batch_fields.gpqr', function( event, formId ) {
		if ( gpqrObj.formId == formId ) {
			setTimeout( function() {
				$( '#gform_{0}'.gformFormat( formId ) ).submit();
			} );
		}
	} );
} );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.