Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

135
Views
Set "to" field on email form i dynamics 365

I am trying to open a new email form in Dynamics 365 using JavaScript. I can easily pre-fill various fields like "Regarding" but when I try to fill the "To" field it just comes out empty.

Here is a small code snippet reproducing my problem:

let contactid = "91be7fec-2142-ec11-8c62-000d3ac23084";
let activityParameters = {};

// Set the regarding field -- this works!
activityParameters["regardingobjectid"] = contactid ;
activityParameters["regardingobjectidname"] = "Regarding your last email";
activityParameters["regardingobjectidtype"] = "contact";

// Set the to field -- this is not working!
var parties = [];
var receiver = {};
receiver["partyid_contact@odata.bind"] = `/contacts(${contactid})`;
receiver["participationtypemask"] = 2; //To
parties.push(receiver);
activityParameters["email_activity_parties"] = parties;
        
await window.parent.Xrm.Navigation.navigateTo(
            { pageType: "entityrecord", entityName: "email", data: activityParameters },
            { target: 2 } // Open in modal
        )

I have also tried some variations based on how lookups are set in other places, like:

var parties = [];
var receiver = {
    activityparty: {
        id: contactid,
        entityType: "contact",
        name: "XXX"
    },
    participationtypemask: 2
};

Googling the problem only gave me solutions for creating emails using the web API (as I have tried above), but I am unsure how to change the code so that navigateTo() recognizes the parameter.

Does anyone have an idea how to go about this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I finally figured it out. Andrew Butenko described how to do it for openForm(), and it turns out the same solution can also be applied to navigateTo().

I'll leave my solution here in case anyone else has the same problem.

let contactid = "91be7fec-2142-ec11-8c62-000d3ac23084";
let activityParameters = {};
​
// Set the to field -- this IS working!
activityParameters["to"] = [{
    id: contactid,
    name: "Contact Name Here",
    entityType: "contact"
}];
      
await window.parent.Xrm.Navigation.navigateTo(
            { pageType: "entityrecord", entityName: "email", data: activityParameters },
            { target: 2 } // Open in modal
        );
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!