Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Get Code of Parent Page

Posted on by Microsoft Employee

Dear Community,


I am having difficulties regarding Sub Pages and Parent Pages.
I have an parent page called x, with a subpage called y.

In Y, you can create new records with a field saying "x" to show that this record belongs to this particular parent.

When creating a new y record, I would like to have the field "parent" filled automatically with the code of the parent page. But honestly, I have no clue how to manage this.

I hope, I described my problem in a understandable way.

Cheers for your help!

The NAV newbie Ben

*This post is locked for comments

  • CU03091147-0 Profile Picture
    CU03091147-0 on at
    Get Code of Parent Page
    Hello Ben,
    can you help me as I also have to do the same thing which you had done.
    My two pages are Price classification and Price Classification Lines.
    I want that whenever a record creates in Price Classification lines then "Classification No." field should be populated by "No." field of the Price classification page.
     
    Please help me.
  • SednaPres Profile Picture
    SednaPres 10 on at
    RE: Get Code of Parent Page

    Is the Garage Code field part of the primary key of the sourcetable of the subpage?  Perhaps a data model of Garage, Garage Line, and Car where Garage Line is the sourcetable for the subpage with a primary key of Garage Code, Line No. (autosplitkey) and a separate field where you would specify the "Card Code" would work for you.

    I had a similar problem where the primary keys of both the parent and child tables were autoincrement ID fields and the subpagelink was on a field that was not part of the primary key of the child table.  Simply adding the field I wanted to link on to the end of the primary key of the child table resolved the issue.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Get Code of Parent Page

    Hello,

    I've got the same problem as @whabada.

    I already set the SubpageLink, all data is listed in the subpage list but I want to pass Id from parent page to child (sub) page during creation of new record in the list in the subpage.

    @whabada - how did you pass your id/No. from your Garage Page to Car list (subpage) using function?

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Get Code of Parent Page

    I solved it myself. I made an function in the Car List part, setting the garage code in global variable, that is passed into every new Record within the onNewRecord function.

    The setGarageCode is called in the Garage Page Code onAfterGetRecord.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Get Code of Parent Page

    Just for clarification whats making me wondering:

    When I use Actions in the Ribbon, using the C/AL Code  "Garage Code" := GETFILTER("Garage Code"); sets the correct value.

    Using the same code on the Page using "SubPageLink" on the Part Page properties doesn't work.

    So using GETFILTER works on RunPageLink Property but not on SubPageLink Property?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Get Code of Parent Page

    People, thanks for your replies.

    The Car list is a Part of the Garage Page, linked via "Part" within the Garage Page. I already set the SubpageLink "Garage Code=FIELD(Code)" and it already just shows the cars listed in this garage. But when adding a new car line, it does not set the new location code automatically.

  • HoangNam Profile Picture
    HoangNam 315 on at
    RE: Get Code of Parent Page

    From NAV 2015, You can reference UpdatePropagation Property of a part.

    If you set UpdatePropagation=Both, When you call a CurrPage.Update from Subpage Y then CurrPage.Update of Page X is also run. So you can call a function at AfterGetRecord, AfterGetCurrRecord,...

    UpdatePropagation.jpg

  • Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Get Code of Parent Page

    How do you link these two pages ? What are the keys. If you look @ Sales Order Page the link is Document NO. and you don't need to add the code to populate them, since that is the link it will auto populate those values, i am think the Garage Code is the key to link those so you need to set that in the link.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Get Code of Parent Page

    Hey people,

    thanks a lot for your quick replies. It is actually like -as Amol pointed out- the sales header and sales Line on the sales order page.

    I have created a table with the corresponding page called Garage. The page contains a subpage called Car list, that also has a table with the name Car. One column of that table is called "Garage code" and is the code of the Parent page Garage .

    Now with every new record on this subpage Car list, I want that column to be filled automatically.

    So basically, it is, as already mentioned, the same procedure as in the Sales order Page. After a few hours of trying today, I was not able to achieve this.

    I saw that the Subpage Sales Line has a function called "setSalesHeader" that is called from the Parent Page Sales Header. And tried this template without any success.

    Also, I actually want this to happen on the Garage page itself, not on the table level - or is this impossible?

    Thanks again!

    Ben

  • Amol Salvi Profile Picture
    Amol Salvi 18,694 on at
    RE: Get Code of Parent Page

    Hi

    How your tables are designed for the functionality you are creating ?

    For reference you can check Sales order where Sales Header and Sales line are connected and Sales header primary key fields inserted automatically in Sales Line when user enter new line

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans