Problem/Motivation

The RelatedID mapping is incredibly powerful, but also complicated. We have regular use cases where there are "incomplete" objects in Salesforce that we don't want to pull up. For example, campaign memberships for contacts that don't have email addresses. We block contacts with no emails from pulling into Drupal, but their campaign memberships try to pull up anyway. Those matching entities in Drupal can't exist without a person on the other end, so we keep writing versions of the same pullPrepull subscriber to block these records until their related item has a corresponding Drupal entity.

I'd like to be able to enable this very specific behavior with a checkbox on the field mapping.

The attached patch provides this facility, and opens the door to other field-level mapping behaviors using interfaces.

After applying this patch, you'll see a checkbox "Confirm Drupal Endpoint Exists" on RelatedID field mappings. Check the box, and any attempts to update or create Drupal records from Salesforce before the related object exists will be rejected, and a warning written to the logs.

Issue fork salesforce-3276564

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

gcb created an issue. See original summary.

gcb’s picture

Status: Active » Needs review
StatusFileSize
new7.18 KB

Status: Needs review » Needs work

The last submitted patch, 2: 3276564_relatedID_pull_disallow-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

gcb’s picture

Status: Needs work » Needs review
StatusFileSize
new7.98 KB

Patching adding schema changes and fixing tests.

aaronbauman’s picture

Issue tags: +Needs tests

Oooh, neat idea.
So, just to make sure i understand, given the example in OP:

if
- "Confirm Drupal endpoint exists" is checked for the CampaignMember.Contact mapping field
- and Contact hasn't been synced to Drupal
then:
- abort CampaignMember pull

Is that right?

I think the name is tricky.
To me, "Confirm Drupal endpoint exists" does not quite explain what is happening.
Maybe there could be a "description" text as well?
Something like "Prevent pull if the referenced record does not exist in Drupal"?
Any additional wordsmithing would appreciated.

Also a test or two would be good.

gcb’s picture

Ok, labeling improved, and also a fix for the form behavior. Tests aren't here yet but let me know what you think of this UX language!

mariacha1’s picture

The value of the field, when checked, is true, not "match", which is preventing the code from running.

    handling:
      match: true

I'm including a patch to fix that.

gcb’s picture

StatusFileSize
new8.57 KB

Re-rolled patch for 5.0.3

gcb’s picture

StatusFileSize
new8.23 KB

Another re-roll against 5.0.4

gcb’s picture

Version: 5.0.x-dev » 5.1.x-dev
Assigned: Unassigned » aaronbauman
aaronbauman’s picture

Have you been using this patch in production?

The annoying thing with "disallow pull" is that it doesn't get automatically retried, ever.
So, even if the parent SFID does eventually get created, it won't trigger another pull attempt for the child record.

This is somewhat tangential, and shouldn't block this patch, but something to consider for folks that want to use this feature.

gcb’s picture

Are you talking about the queue item permanently being disallowed, or somehow the specific SF ID itself permanently getting disallowed? Because the latter is definitely a problem! The former doesn't seem so bad, although it would certainly be nice if it allowed some retries -- I can easily imagine cases where a retry would be likely to sync successfully. If that's the case, we could look at a different type of sync rejection. Maybe "postponePull"?

aaronbauman’s picture

I'm talking about the situation where a subscriber might want to postpone pull.

The "disallowPull" method doesn't support this, outside of manually forcing another pull attempt.

There's no permanent disallow that i know of...

aaronbauman’s picture

Status: Needs review » Reviewed & tested by the community
Related issues: +#3529409: Improve pull queue exception handling and subscriber options

This is good to go i think.

Also opened related issue #3529409: Improve pull queue exception handling and subscriber options

  • aaronbauman committed f1110bfa on 5.1.x authored by gcb
    Issue #3276564: Allow RelatedID mapped fields to disallow pulls
    
aaronbauman’s picture

Status: Reviewed & tested by the community » Fixed

Merged, thanks for your work

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.

  • aaronbauman committed f1110bfa on sniff-test authored by gcb
    Issue #3276564: Allow RelatedID mapped fields to disallow pulls
    
gcb’s picture

@aaronbauman thanks for merging, and sorry about dropping the convo here!

Status: Fixed » Closed (fixed)

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