gppa_updated_batch_fields

  1. Description
  2. Usage
  3. Parameters
  4. Examples
    1. Listen for updates on a specific field.
    2. Select All Populated Checkboxes
    3. Auto-submit after fields are populated via QR code scan.

Description

An event that gets triggered when Populate Anything has dynamically updated a field’s choices or value.

Usage

$( document ).on( 'gppa_updated_batch_fields', function() { 
    // Do your magic!
} );

Parameters

  • event Event

    The JavaScript event for the gppa_updated_batch_fields request.

  • formId int

    The ID of the form for which the fields were updated.

  • updatedFieldIds array

    An array of IDs for fields that were updated.

  • triggerInputId array

    An array of IDs for fields that triggered the update.

  • instance GPPopulateAnything

    The current instance of GPPopulateAnything.

Examples

Listen for updates on a specific field.

/**
 * Gravity Perks // Populate Anything // Listen for Populate Anything Updates on a Specific Field
 * https://gravitywiz.com/documentation/gravity-forms-populate-anything/
 */
$( document ).on( 'gppa_updated_batch_fields', function( e, formId, updatedFieldIDs ) {
	var targetFieldId = 3;
	if ( parseInt( formId ) === GFFORMID && $.inArray( String( targetFieldId ), updatedFieldIDs ) !== -1 ) {
		console.log( 'Target field updated!' );
	}
} );

Select All Populated Checkboxes

/**
 * We're no longer using the experimental folder for experimental snippets. 🚧
 * You can now find the snippet here:
 * https://gravitywiz.com/snippet-library/gppa-select-all-checkboxes/
 */

Auto-submit after fields are populated via QR code scan.

Use GP QR Code to scan a QR code and Populate Anything to dynamically populate data based on the scanned QR code. Then, with this snippet, you can wait for Populate Anything to finish updating the fields and automatically submit the form.

/**
 * 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();
			} );
		}
	} );
} );