Add "Entity Has Salesforce Mapping" condition

Created on 9 June 2025, about 1 month ago

Problem/Motivation

Workflows often need to check if an entity type/bundle has any Salesforce mapping configured before attempting sync operations.

This condition would enable:
- Conditional workflow execution based on mapping existence
- Preventing errors when no mapping exists
- Building dynamic workflows that adapt to configuration

Steps to reproduce

1. Create an ECA model
2. Need to check if entity has Salesforce mapping
3. No simple condition available

Proposed resolution

Add a condition plugin that checks if the entity type/bundle has any active Salesforce mapping.

Remaining tasks

- [ ] Create condition plugin
- [ ] Query mapping storage for entity type/bundle
- [ ] Return TRUE/FALSE
- [ ] Test with various entity types

User interface changes

New condition "Entity has Salesforce mapping" will appear in ECA.

API changes

None.

Data model changes

None.

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States camoa

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

Comments & Activities

  • Issue created by @camoa
  • πŸ‡ΊπŸ‡ΈUnited States camoa
  • πŸ‡ΊπŸ‡ΈUnited States camoa

    Entity Is Mapped to Salesforce condition implemented and committed.

    What it does: Check if a Drupal entity has a Salesforce mapping. Optionally stores the mapping information in tokens for use by subsequent actions. Essential for conditional workflows based on Salesforce sync status.

    Key features:

    • Check for ANY mapping or specific mapping ID
    • Works with entity from context or token
    • Optionally stores mapping info in tokens (eliminates need for separate action)
    • Supports multiple mappings per entity
    • Clean pass/fail condition for ECA workflows

    Configuration options:

    • Entity token: Optional, uses context entity if empty
    • Mapping ID: Optional, check for specific mapping
    • Store mapping tokens: Save mapping info for subsequent actions
    • Token name: Name for stored mapping data

    Stored tokens (when enabled):

    • [token:salesforce_id] - The Salesforce record ID
    • [token:salesforce_object_type] - Object type (Contact, Lead, etc.)
    • [token:mapping_id] - Salesforce mapping configuration ID
    • [token:salesforce_url] - Direct Salesforce URL
    • [token:last_sync_status], [token:last_sync_action]

    Example usage:

    • Entity view: Only show Salesforce fields if entity is mapped
    • Complete workflow: Condition stores tokens, next action uses [token:salesforce_id] to fetch fields
    • Specific mapping: Check if entity uses "contact_mapping" specifically
    • Pre-operation check: Verify mapping exists before sync operations

    Testing: Successfully tested with mapped and unmapped entities. Token storage works perfectly, enabling streamlined workflows without separate mapping lookup actions.

    Files added/changed:

    • src/Plugin/ECA/Condition/EntityIsMapped.php (new condition)
    • config/schema/salesforce_eca.schema.yml (configuration schema)

    Now you can create conditional workflows based on Salesforce mapping status, with optional token storage for maximum efficiency.

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

Production build 0.71.5 2024