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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Several fields in a fo...
Power Apps
Unanswered

Several fields in a form from a related entity

(0) ShareShare
ReportReport
Posted on by 144

I have a two entities with a relationship between two fields. I use model-driven application, and form that is customized. The Customer Name in Order entity is a Lookup field to Customer.

I have a Customer endity with relation to Order Entity.

Order.PNG

In my order form in CDS, i have added the Customer Name, and the lookup to Customer works well.

 

My question is: How to i add the e-mail and phone number (from Customer entity) to the Order form. I must have the e-mail and phone fields for the selected customer in the Order form.

 

 

 

I have the same question (0)
  • EricRegnier Profile Picture
    8,720 Most Valuable Professional on at

    Hi @TrulsB,

    You can easily achieve this with Quick View Forms. Quick View Forms allows to display fields from the related entity to the parent entity's form. The advantage of quick view forms is that you don't have to re-create these fields on the Order entity and sync/maintain the values as they change. They reference the data directly from the source entity (i.e. Customer).

    Here's are the simple steps to create a customer quick view form and add it to your order form:

    https://docs.microsoft.com/en-us/powerapps/maker/model-driven-apps/create-edit-quick-view-forms

    Hope this helps!

  • summitb Profile Picture
    on at

    You can use a Quick view form in the Order form. A quick view control on a model-driven app form displays data from a record that is selected in a lookup on the form. The data displayed in the control is defined using a quick view form. The data displayed is not editable, but when the primary field is included in the quick view form, it becomes a link to open the related record. More information: Create and edit quick view forms

  • TrulsB Profile Picture
    144 on at

    Ok, thanks for the tip With the Quick View form.  

    In the order table/form, i have lookup to the Customer table (Customer Field).  

     

    In the Order form, i like to have one Field for phone, and one Field for e-mail. Is it possible to fill in these Field for phone and e-mail automaticly With data from the actual Customer record?

     

     

     
    Is it possible to fill in these fields for telephone and e-mail automatically with data from the Customer table?
  • summitb Profile Picture
    on at

    You can do use web-resource to populate it in the form. You can put something like this onLoad event.

    var customerid = Xrm.Page.getAttribute("customerid").getValue()[0].id;
    
     var urlSelect = "http://YourServer//api/data/v9.1/" +
     "/Customers?$select=email&$filter=customerid eq guid'" + customerid + "'";
    
     $.ajax({
     type: "GET",
     contentType: "application/json; charset=utf-8",
     datatype: "json",
     url: urlSelect,
     beforeSend: function (XMLHttpRequest) {
     XMLHttpRequest.setRequestHeader("Accept", "application/json");
     },
     success: function (data, textStatus, XmlHttpRequest) {
    Xrm.Page.data.entity.attributes.get("telephone").setValue(data.d.results[0].email);
     },
     error: function (XmlHttpRequest, textStatus, errorThrown) {
     alert('Error');
     }
     });

     

  • EricRegnier Profile Picture
    8,720 Most Valuable Professional on at

    Hi @TrulsB, not sure if you already resolved this, but if you create a quick view form with those fields on it will automatically display on the order form as soon as you select the customer lookup. My recommendation is to as much as possible stay away from custom code (aka customizations) and try to leverage out-of-the-box. 

     

    BTW the code provided by @summitb uses deprecated code such as Xrm.Page. If you do end up using JavaScript, suggest to use the Xrm.WebApi.retrieveRecord rather than jQuery. Here's the updated (untested) supported code:

     

    async function OnCustomerChanged(context) {
     let formContext = context.getFormContext();
    
     if(!formContext.getAttribute("customerid").getValue()) return;
     
     let customerId = formContext.getAttribute("customerid").getValue()[0].id;
     let customer = await Xrm.WebApi.retrieveRecord("account", customerId, "?$select=phonenumber,emailaddress1");
    
     formContext.getAttribute("telephone").setValue(customer.phonenumber);
     //set other fields
    }

     

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard