Introduction
Would you like to send checkbox values to Salesforce? By default, Salesforce only accepts boolean values for the checkbox field (true or false values). But with WPForms Checkbox, Multiple Choice and Dropdowns use the labels so these types of fields won’t be mapped and show correctly inside Salesforce.
In this tutorial, we’re going to walk you through how to get these values assigned to Salesforce.
Enabling the Show Values option
First, we’ll need to add a small snippet from this tutorial so that we can place values into the Show Values option for Checkbox, Multiple Choice and Dropdowns.
/** * Show values in Dropdown, checkboxes, and Multiple Choice. * * @link https://wpforms.com/developers/add-field-values-for-dropdown-checkboxes-and-multiple-choice-fields/ * */ add_action( 'wpforms_fields_show_options_setting', '__return_true' );
If you need any help in adding any of these snippets to your site, please check out this tutorial.
Creating the form
First, you’ll need to create the form and add your fields including your Checkbox, Dropdown or Multiple Choice form fields.
If you need any help in creating a form that connects with Salesforce, please take a look at this documentation.
In this tutorial, we’ve added a Checkbox field. Once we’ve added that field, we can click on the Advanced tab and toggle the option for Show Values.
Adding the snippet
Next, you’ll need to copy this snippet to your site. If you need any help in how to add snippets to your site, please see this tutorial.
/** * Send checkbox values to Salesforce * * @link https://wpforms.com/developers/how-to-send-checkbox-values-to-salesforce/ */ function wpf_dev_checkbox_salesforce( $field_value, $format ) { $fields = $format->get_prop( 'fields' ); $field_id = $format->get_prop( 'wpf_field_id' ); if ( is_array( $fields ) && isset( $fields[ $field_id ][ 'value_raw' ] ) ) { return filter_var( $fields[ $field_id ][ 'value_raw' ], FILTER_VALIDATE_BOOLEAN ); } return $field_value; } add_filter( 'wpforms_salesforce_provider_process_format_field_boolean_value', 'wpf_dev_checkbox_salesforce', 10, 2 );
Adding your values
For this tutorial, we’ve added a Checkbox field, now we’ll need to set the text true to each of the checkbox options. This will allow WPForms to pass over the selection to Salesforce.
Mapping the form fields
Next, in order to get the form field information from the form to Salesforce, you’ll need to map these fields over, to do that, click on the Marketing tab and then select Salesforce.
We’re going to set up our Salesforce connection to map the field What classes are you interested in to the Lead form Product Interest.
Once you’ve mapped the fields and saved the form, you will now see your checkbox items into Salesforce.
And that’s it! Would you like to send over the field values using the Webhooks addon? Take a look at our tutorial on How to Send Field Values with Webhooks.