Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV forum
Answered

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

  • 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,638 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,690 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

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

    Honestly i did not understand your query, please try to explain using the actual page names and what are you trying to do. You can always call the other functions ofother pages or records creating respective variables and calling that function.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,420 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,672 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans