gform_salesforce_object_data

Description

Filters the object sent to Salesforce when processing the feed.

Usage

The following would apply to all forms:

add_filter( 'gform_salesforce_object_data', 'your_function_name', 10, 4 );

To target a specific form, append the FORMID to the hook name.

add_filter( 'gform_salesforce_object_data_123', 'your_function_name', 10, 4 );

Parameters

Examples

Set LeadSource before sending to Salesforce for all forms.

// Set LeadSource before sending to Salesforce for all forms
add_filter( 'gform_salesforce_object_data', function( $body, $form, $entry, $feed ) {

    // Log the initial state of the $body before modifications
    gf_salesforce()->log_debug( 'gform_salesforce_object_data: Original Salesforce object data: ' . print_r( $body, true ) );

    // Log form and entry IDs.

    gf_salesforce()->log_debug( 'gform_salesforce_object_data: Processing form ID ' . $form['id'] . ' and entry ID ' . $entry['id'] );
	
    $body['LeadSource'] = 'Website';

    // Log the modified $body before returning it
    gf_salesforce()->log_debug( 'gform_salesforce_object_data: Final Salesforce object data: ' . print_r( $body, true ) );

    // Always return the body
    return $body;

}, 10, 4 );

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Since

This filter was added in Gravity Forms Salesforce Add-On version 1.0.

Source Code

This filter is located in class-gf-salesforce.php.