Skip to main content

Notifications

Community site session details

Community site session details

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

In Javascript, access parent entity record when adding new child record

(0) ShareShare
ReportReport
Posted on by 306

In our model-driven app, I have a 1:N relationship between 2 entities.  On the form to add related child records, I want to use javascript on the onChange event of a lookup field to populate another field on the form.  To get the data for the other field, I need to access the parent entity record and get data from it and other entities related to it.  Can anyone provide an example of how to access the parent and other related entities in javascript when child record hasn't been saved yet?

  • tschopp Profile Picture
    306 on at
    Re: In Javascript, access parent entity record when adding new child record

    Thanks @DianaBirkelbach .  I see now that if I add a lookup control for the parent on the form, it is populated in Create Mode and I can access it's value from the formContext in JS.

  • Verified answer
    Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at
    Re: In Javascript, access parent entity record when adding new child record

    Hi @tschopp , 

     

    If it's a child entity, then you have a lookup to the parent record. This lookup is usually filled in on the form, even when the child record is not saved. When the form is opened, the platform will pass this parameters (and in case you open the form using code, you can do that too).

    So even in "Create Mode" you can grab the id of the parent, and can make fetches for related records.

    Please let me know, in case you need more details.

     

    Kind regards,

    Diana

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

🌸 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…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Power Apps Pro Dev & ISV

#1
WarrenBelz Profile Picture

WarrenBelz 87 Most Valuable Professional

#2
mmbr1606 Profile Picture

mmbr1606 71 Super User 2025 Season 1

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 65 Super User 2025 Season 1

Overall leaderboard