We have a full schema for each mapped field - including length when applicable.
SF push module should do a better job of preventing pushing invalid values to SF.

Comments

aaronbauman created an issue. See original summary.

mariacha1’s picture

Assigned: Unassigned » mariacha1

I need this functionality for my current project, so I'm taking this one on.

mariacha1’s picture

Status: Active » Needs review
StatusFileSize
new1.88 KB

Initial attempt attached. Note: This only imposes a length limit for strings and textareas for now. It's not configurable at all -- the user has no say in whether the maxlength is imposed. Adds this helper function that executes immediately before pushing:


/**
 * Helper function to truncate the value to send to Salesforce.
 *
 * @param string $value
 * @param array $salesforce_object_information
 */
function _salesforce_push_impose_max_length(&$value, $salesforce_object_information) {
  if (empty($value) || empty($salesforce_object_information)) {
    return;
  }

  $salesforce_object_types_to_truncate = array(
    'string',
    'textarea',
  );
  $salesforce_object_type = $salesforce_object_information['type'];
  $salesforce_object_max_length = $salesforce_object_information['length'];

  if ($value && in_array($salesforce_object_type, $salesforce_object_types_to_truncate) && $salesforce_object_max_length && strlen($value) > $salesforce_object_max_length) {
    $value = text_summary($value, NULL, $salesforce_object_max_length);
  }
}

The function does what it should, but the feature set could be nicer -- I'm open to feedback.

mariacha1’s picture

At the very least, this behavior should be moved to salesforce_mapping_property_fieldmap_pull_value. Would be best if this could be configured on a per-mapping basis. Ultimate user experience would probably be to compare size values on a per-mapping basis when validating the form.

mariacha1’s picture

Status: Needs review » Needs work
wxactly’s picture

StatusFileSize
new1.99 KB

Wrapping each of the property lookups here in isset to prevent errors when these fields don't exist

aaronbauman’s picture

Status: Needs work » Closed (won't fix)

7.x is no longer supported

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.