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.

Comments

scambler created an issue. See original summary.

bkildow’s picture

Status: Needs review » Reviewed & tested by the community

The patch here works for me!

  • aaronbauman committed 8f3fe8ce on 5.1.x
    Issue #3506472 by scambler: Record type filter cleared whenever saving...

  • aaronbauman committed e3da3d4a on 5.0.x
    Issue #3506472 by scambler: Record type filter cleared whenever saving...
aaronbauman’s picture

Status: Reviewed & tested by the community » Fixed

Commited, thanks

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.