Record type filter cleared whenever saving mapping fields

Created on 13 February 2025, about 2 months ago

Problem/Motivation

Whenever saving the mapping fields, it clears the saved values for the "Record Types to Request" setting.

Steps to reproduce

  • Create a mapping to SF Contact
  • Set and save the "Record Types to Request"
  • Switch to the Fields tab and save
  • Switch back to the Settings tab and the previous settings are no longer saved

Proposed resolution

Move the buildEntity method from SalesforceMappingFormBase to SalesforceMappingFormCrudBase.
SalesforceMappingFieldsForm extends SalesforceMappingFormBase, therefore whenever saving the fields form, it resets the record type.

/**
   * {@inheritdoc}
   */
  public function buildEntity(array $form, FormStateInterface $form_state) {
    $entity = parent::buildEntity($form, $form_state);
    $record_types = $form_state->getValue('pull_record_type_filter');
    if (!empty($record_types)) {
      $record_types = array_filter($record_types);
      if (!empty($record_types)) {
        $record_types = array_values($record_types);
      }
    }
    $entity->set('pull_record_type_filter', $record_types ?? []);
    return $entity;
  }

Remaining tasks

Review patch and test.

πŸ› Bug report
Status

Needs review

Version

5.1

Component

salesforce_mapping_ui.module

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024