web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

Incoming Email Always Associates Duplicate Contact from Default BU Unable to Override in Plugin

(3) ShareShare
ReportReport
Posted on by 1,020
Setup:
 
  • We have an ARC rule configured to:
    • Automatically create a Contact if not found.
    • Allow unknown senders to send emails.
  • The system correctly creates a Case when an email is received.
  • However, in our scenario, we have duplicate active Contacts:
    • Contact A belongs to BU "ABC"
    • Contact B belongs to BU "XYZ"
  • Each Contact has a custom flag indicating its BU assignment.
  • When sending an email to the XYZ BU-specific queue/email, the system still associates Contact A (ABC BU) as the from party on the email activity.
What I've Tried:
  1. Post-Operation Plugin (on Create/Update of Email):
    1. Objective: Update the From field based on the Contact set on the Case (Case is correctly set in Regarding).
    2. Code Snippet:- 
    3. but i am getting an error as - Error occurred while processing Case: Cannot update parties unless email is in draft status.
      ​​​​​​
  2. ​​​​​Pre-Operation Plugin (on Create of Email):
     
    1. Identify and set the correct Contact in the From activity party before the record is created.
    2. Code Snippet:- 
    3. Unfortunately, this does not override the default Contact being set by the system. It continues to associate Contact A from the ABC BU.
       
  3. Additionally

    I also reviewed the official Microsoft documentation for the Email entity here, which mentions the "_emailsender_value" field. This corresponds to the From party when the email status is "Received", but it appears that this field is system-controlled and not directly modifiable once the email is created.

    ​​​​​​​Any guidance or workaround would be appreciated! Thanks in advance!
Categories:
I have the same question (0)
  • Suggested answer
    Holly Huffman Profile Picture
    6,538 Super User 2025 Season 2 on at
    Good morning, afternoon, or evening :) depending on your location!
     
    Key Observations:
    1. The _emailsender_value field is system-controlled and cannot be modified once the email is created.
    2. The error "Cannot update parties unless email is in draft status" indicates that updates to the "From" field are restricted for emails in a "Received" status.
    3. The ARC rule is defaulting to the first matching contact, which may not align with your BU-specific requirements.
    Suggested Workarounds:
    1. Modify the ARC Rule Logic:
    • If possible, adjust the ARC rule to include additional criteria for selecting the correct contact. For example, use the custom BU assignment flag to prioritize contacts from the correct BU.
    2. Pre-Operation Plugin Enhancements:
    • Ensure that your Pre-Operation Plugin logic is executed before the system sets the "From" field. You can achieve this by:
      • Registering the plugin on the Create message of the Email entity with a Pre-Validation stage.
      • In the plugin, explicitly set the "From" field using the correct contact reference:
        Entity fromParty = new Entity("activityparty");
        fromParty["partyid"] = new EntityReference("contact", contact.Id);

        entity["from"] = new EntityCollection(new List<Entity> { fromParty });
        tracingService.Trace("Updated 'From' field with matched Contact.");
    3. Custom Workflow or Power Automate Flow:
    • Use a custom workflow or Power Automate flow to reassign the "From" party after the email is created. While this won't modify the system-controlled _emailsender_value, it can update related fields or create a new email activity with the correct "From" party.
    4. Custom Email Creation Process:
    • Instead of relying on the ARC rule to create emails, implement a custom process to handle incoming emails. This process can:
      • Identify the correct contact based on BU-specific criteria.
      • Create the email activity with the correct "From" party.
     
    Hope this helps some!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 45 Most Valuable Professional

#2
iampranjal Profile Picture

iampranjal 36

#3
Satyam Prakash Profile Picture

Satyam Prakash 31

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans