Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Populate a field on load

(0) ShareShare
ReportReport
Posted on by 4

Hi,

 I want to populate a field which is  on contact email field  on another entity pde .

pde is related to case and there is no relation from pde to contact.

Thanks

  • Leah Ju Profile Picture
    Microsoft Employee on at
    RE: Populate a field on load

    Hi Partner,

    What is the relationship between these three entities?

    I know that case and pde are 1:N relationship, what about case and contact?

    1:N or N:1?

    Based on your code, case and contact are 1:N, so one pde has one case, but one case related to multiple contacts, which contact's email do you need?

    The 1:N relationship you used is custom?

    There are OOB N:1 relationships between case and contact, why not use it?

    pastedimage1681977492745v2.png

  • EKL Profile Picture
    4 on at
    RE: Populate a field on load

    Hello Guido,

    With javascript, I got the following code and the field to populate is written in a loop in One To Many Relationships, how to populate field and which line I need to assign.

    Is it after the for loop.

    function populateCaseFieldsOnPDE(executionContext)

    {

      debugger;

      var formContext = executionContext.getFormContext();

      var associatedCase = formContext.getAttribute("har_associatedcase").getValue();

      if(associatedCase != null)

      {

      var caseId = formContext.getAttribute("har_associatedcase").getValue()[0].id.slice(1, -1);

    var req = new XMLHttpRequest();

    req.open("GET", Xrm.Utility.getGlobalContext().getClientUrl() + "/api/data/v9.2/incidents(" + caseId + ")?$select=har_klscodepostcode,har_siteaddress,har_customercontactname,har_sitecontactname&$expand=har_incident_contact_Case($select=emailaddress1)", false);

    req.setRequestHeader("OData-MaxVersion", "4.0");

    req.setRequestHeader("OData-Version", "4.0");

    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

    req.setRequestHeader("Accept", "application/json");

    req.setRequestHeader("Prefer", "odata.include-annotations=*");

    req.onreadystatechange = function () {

    if (this.readyState === 4) {

    req.onreadystatechange = null;

    if (this.status === 200) {

    var result = JSON.parse(this.response);

    console.log(result);

    // Columns

    var incidentid = result["incidentid"]; // Guid

    var har_klscodepostcode = result["har_klspostcode"]; // Text

    var har_siteaddress = result["har_siteaddress"]; // Multiline Text

    var har_customercontactname = result["har_customercontactname"]; // Text

    var har_sitecontactname = result["har_sitecontactname"]; // Text

    // One To Many Relationships

    for (var j = 0; j < result.har_incident_contact_Case.length; j++) {

    var har_incident_contact_Case_emailaddress1 = result.har_incident_contact_Case[j]["emailaddress1"]; // Text

    }

    } else {

    console.log(this.responseText);

    }

    }

    };

    req.send();

      }

    }

    Thanks

  • Guido Preite Profile Picture
    54,077 Moderator on at
    RE: Populate a field on load

    if there is a relation between case or contact (or one between case, another entity and after contact) it is possible with some javascript (Xrm.WebApi or similar)

    hope it helps

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

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

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 181 Super User 2025 Season 1

#2
Siv Sagar Profile Picture

Siv Sagar 149 Super User 2025 Season 1

#3
Vahid Ghafarpour Profile Picture

Vahid Ghafarpour 124 Super User 2025 Season 1

Product updates

Dynamics 365 release plans