Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Pro Dev & ISV
Unanswered

Dataverse Model Driven App mapping from Child Entity Main form to Parent Entity Quick Create form

(0) ShareShare
ReportReport
Posted on by 40

In my dataverse model driven app I have an entity "order" and an entity "issue".

The relationship between them is N to 1 ie multiple orders, 1 issue.

If I am creating a new order from the main order form there is a lookup field to "issue". I can either select an existing "issue" or (if required) create a new one using the quick create form.

When using the quick create form I would like the field "account" to automatically populate from what is on the order form. I can see how to map from parent entity "issue" to child entiy "order" but understand you can not create mapping from child entity to parent entity.

 

I have read some blogs on how to do this using js and local storage but the local storage option sounds like it may be a little unreliable.

 

Any help on the best way to handle this would be really helpful. Thankyou.

  • cchannon Profile Picture
    4,702 Super User 2025 Season 1 on at
    Re: Dataverse Model Driven App mapping from Child Entity Main form to Parent Entity Quick Create form

    @a33ik 's code just gets you the "parent" record (in your case, the Issue). From there, you need to do a retrieveRecord call using the client script API to get the accountid value. It would look something like this:

    Xrm.WebApi.retrieveRecord(parentRecordReference.entityType, parentRecordReference.id, "?$select=accountid").then(
     (success) => {console.log(success.accountid)}, 
     (error) => {console.error(error.message)}
    );
  • sharonsammy123 Profile Picture
    40 on at
    Re: Dataverse Model Driven App mapping from Child Entity Main form to Parent Entity Quick Create form

    Thanks, I have had a look at your code (pasted below).

    To clarify,  I have 3 entities.
     
    Account     (parent of Order and Issue)
    Issue    (child of Account, parent of Order. The "accountid" field is a required field)
    Order     (child of Issue and Account. The "accountid" field is a required field. The "issueid" field is not required, but recommended)
     
    From my Order main form I would like to pass the "accountid" to the new Issue if someone wants to create a new issue using the quick create form.
     
    I have pasted your code below. I understand I upload this as a web resource and create an onload event on the quick create form.
     
    I am unsure of the references that I use in the code to get the "accountid", Can you assist?
     
    Your JavaScript
     
    function quickCreateOnLoad(){
    //this variable contains entity reference to the parent record
    var parentRecordReference = Xrm.Utility.getPageContext().input.createFromEntity;
     
    //if this variable is null then Quick Create Form was called from the Global Menu
    //or from some other code without setting the parent record context
    if (parentRecordReference == null){
    return;
    }
     
    //you can use value of parentRecordReference in your code
    console.log(parentRecordReference.id);
    console.log(parentRecordReference.entityType);
    console.log(parentRecordReference.name);
    }
     
     
  • a33ik Profile Picture
    3,304 Most Valuable Professional on at
    Re: Dataverse Model Driven App mapping from Child Entity Main form to Parent Entity Quick Create form

    Hello,

    You can check my post - https://butenko.pro/2020/09/15/js-how-to-get-the-originating-record-reference-in-the-form-script-of-the-quick-create-form/

    In the post I described on how to get the parent entity and using WebApi and some JavaScript you can populate the lookup from the parent entity.

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

Announcing the Engage with the Community forum!

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Apps - Power Apps Pro Dev & ISV

#1
WarrenBelz Profile Picture

WarrenBelz 109 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 82 Super User 2025 Season 1

#3
mmbr1606 Profile Picture

mmbr1606 71 Super User 2025 Season 1

Overall leaderboard