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...
Answered

Retrieve value of lookup field from activity entity to email entity of lookup field

(6) ShareShare
ReportReport
Posted on by 5,514
Hi 
 
I have a lookup field1 in activity entity I should retrieve its value and update in Email entity of lookup field2 ....
 
How can I achieve this any example will help me 
 
 
Thanks 
 
Categories:
I have the same question (0)
  • Verified answer
    Daivat Vartak (v-9davar) Profile Picture
    7,835 Super User 2025 Season 2 on at
    Hello Sandeepc,
     

    You can achieve this using a Dynamics 365 workflow or a Power Automate flow. Here's how you can set it up with examples for both:

    Scenario: When a Meeting (d365_meeting) record is created or a specific field changes, retrieve the value from the CC lookup field (d365_cc) and update the TO lookup field (d365_to) of a newly created Email activity related to that Meeting.

    Option 1: Dynamics 365 Workflow (Classic)

    1. Navigate to Settings > Processes.

    2. Click "New".

    3. Enter a Process name (e.g., "Copy Meeting CC to Email TO").

    4. Set the Category to "Workflow".

    5. Set the Entity to "Meeting (d365_meeting)".

    6. Choose the Scope that fits your requirement (User, Business Unit, Parent: Child Business Units, or Organization).

    7. Check the "Run this workflow in the background (recommended)" option.

    8. Click "OK".

    9. Define the Trigger:

      • Under "Start when", select:

        • "Record is created"

        • "Record fields change" (and select the field that, when changed, should trigger this - e.g., the CC lookup field itself or a status change indicating completion). 
         

    10. Add a Condition (Optional but Recommended):

      • Click "Add Step" and select "Check Condition".

      • Define a condition to ensure you only proceed if the CC lookup field has a value (e.g., d365_cc Does not equal null). 

    11. Add a Step to Create the Email:

       

      • Click "Add Step" and select "Create Record".

      • In the "Create:" dropdown, select "Email Message".

      • In the "Set Properties" section, click "Set Properties".

      • In the Email form:

        • Regarding: Set this to the Meeting record using the lookup from the workflow context. In the lookup field, select "Regarding (Meeting)" and click "Add".

        • To: This is where you'll copy the CC value.

          • Click in the "To" field.

          • In the "Look For" dropdown, select the entity type of the CC lookup field (e.g., "Contact", "Account", or "User").

          • In the "Select" dropdown, choose "CC (Meeting)".

          • Select the appropriate field from the related CC record that represents the recipient (e.g., "Email Address" for Contact or User, "Primary Email" for Account).

          • Click "Add". 

        • Subject: Set a relevant subject (e.g., "Follow-up from Meeting").

        • Description: Add any default email body content. 

      • Click "Save and Close".

    12. Add a Step to Activate the Email (Optional):

      • Click "Add Step" and select "Update Record".

      • In the "Update:" dropdown, select "Email Message".

      • Click "Select" and choose the "Email Message" created in the previous step "(Step: Create Email Message)".

      • In the "Set Properties" section, click "Set Properties".

      • Set the "Status" to "Pending Send" or "Sent" as needed.

      • Click "Save and Close". 

    13. Save and Activate the Workflow.

       


    14.  

    Option 2: Power Automate Flow

    1. Go to Power Automate (https://make.powerautomate.com/).

    2. Click "Create" and choose "Automated cloud flow".

    3. Enter a Flow name (e.g., "Copy Meeting CC to Email TO").

    4. Search for the "Microsoft Dataverse" connector and select the trigger "When a row is added, modified or deleted".

    5. Configure the trigger:

      • Environment: Choose your Dynamics 365 environment.

      • Table name: Select "Meetings (d365_meeting)".

      • Change type: Select "Added" or "Modified" (or both based on your requirement).

      • Scope: Choose the appropriate scope.

      • Select columns: If you chose "Modified", select the d365_cc field to trigger only when it changes (or other relevant fields). 

    6. Add a Condition (Optional but Recommended):

      • Click "+ New step" and search for "Condition".

      • Configure the condition to check if the d365_cc field has a value. In the dynamic content, select the d365_cc lookup field and set the condition to "is not null". 

    7. Add an action under the "If yes" branch to create the Email:

      • Click "+ Add an action" and search for "Microsoft Dataverse".

      • Select the action "Add a new row".

      • Table name: Select "Emails".

      • Click "Show advanced options".

      • Regarding (Value):

        • For the "Item ID", select the Meeting (Meetings) dynamic content (the ID of the triggering meeting).

        • For the "Table logical name", enter d365_meeting. 

      • To (Recipients): This requires an array of recipient objects. The structure depends on the entity type of your CC lookup.

        • If d365_cc is a lookup to Contact:
          [
            {
              "activitypartyid": "@{guid()}",
              "participationtypemask": 2,
              "partyid_contactid@odata.bind": "/contacts(@{triggerOutputs()?['body/d365_cc/contactid']})"
            }
          ]

        • If d365_cc is a lookup to Account:
          [
            {
              "activitypartyid": "@{guid()}",
              "participationtypemask": 2,
              "partyid_accountid@odata.bind": "/accounts(@{triggerOutputs()?['body/d365_cc/accountid']})"
            }
          ]

        • If d365_cc is a lookup to User:
          [
            {
              "activitypartyid": "@{guid()}",
              "participationtypemask": 2,
              "partyid_systemuserid@odata.bind": "/systemusers(@{triggerOutputs()?['body/d365_cc/systemuserid']})"
            }
          ]

          Replace /contacts(...), /accounts(...), and /systemusers(...) with the correct OData bind path for your CC lookup entity. 

      • Subject: Enter a relevant subject (e.g., "Follow-up from Meeting").

      • Description: Add any default email body content. 

    8. Add an action to update the Email status (Optional):

      • Click "+ Add an action" and search for "Microsoft Dataverse".

      • Select the action "Update a row".

      • Table name: Select "Emails".

      • Row ID: Select the Activity Id dynamic content from the "Add a new row" (Create Email) step.

      • Set the "Status" and "Status Reason" fields to "Pending Send" or "Sent" as needed. 

    9. Save the Flow.

       


    10.  

    Explanation of the Power Automate "To" Field:

    • The "To" field in the Email entity is an Activity Party, which can hold multiple recipients of different entity types.
    • You need to create a JSON array of recipient objects.
    • activitypartyid: A unique GUID for this recipient record.
    • participationtypemask: Set to 2 for "To" recipients.
    • partyid_ENTITYLOGICALNAME@odata.bind: This is crucial for linking the recipient to the correct record.

      • Replace ENTITYLOGICALNAME with the lowercase logical name of the entity your d365_cc lookup points to (e.g., contact, account, systemuser).
      • Replace @{'triggerOutputs()?['body/d365_cc/ENTITYIDFIELD']'} with the dynamic content that holds the ID of the looked-up record. The ENTITYIDFIELD will be the primary key field of the looked-up entity (e.g., contactid, accountid, systemuserid). 

      •  

    •  

    Choosing Between Workflow and Power Automate:

    • Workflows are generally simpler for basic, synchronous or asynchronous automation within Dynamics 365.
    • Power Automate offers more flexibility, better integration with other services, and more advanced logic capabilities. For this scenario, Power Automate might be slightly more complex due to the array structure for the "To" field but provides more control.

    •  

    Remember to test your chosen solution thoroughly in a non-production environment before deploying it to your production instance. Make sure the lookup field d365_cc on the d365_meeting entity is correctly populated with the desired recipient(s) for the email. If the CC field can hold multiple values, you'll need to adjust the Power Automate flow to iterate through them and create multiple "To" recipients in the Email.

     
    If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more. If you have further questions, please feel free to contact me.
     
    My response was crafted with AI assistance and tailored to provide detailed and actionable guidance for your Microsoft Dynamics 365 query.
     
    Regards,
    Daivat Vartak
  • sandeepc Profile Picture
    5,514 on at
    Can we do this using a Java script if yes how

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 51 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 38 Super User 2025 Season 2

#3
#ManoVerse Profile Picture

#ManoVerse 31

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans