Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Passing variables between subpages

(1) ShareShare
ReportReport
Posted on by 25
Hi all,
 
I have a card page which is linked to some header table, and in the card page, two subpages (both listparts) - one is a lines page (lines of header) and the other is some item page (individual items of the line). So all three tables/parts work together in some way. What I am trying to do seems very simple but for some reason it is causing me so many headaches.. Simply put, when entering a new record in the item subpage, it should automatically enter in the line no. in a field in item page of the current selected line. This same functionality works when entering a new line record. It automatically pulls the header No. into a field in the new line rec. So with the items, this doesn't happen and instead I get this message when clicking on a new line:
This message makes sense as the item records shown should only be linked to the specific line selected but I'm not sure how to solve this. The easy solution is to have this filter message present until a user manually enters in the correct line no., but the issue is that I want to hide that field and automatically do it. Another solution I thought would be to pass a variable between subpages and that is my main focus now (unless someone could explain how to make it so it automatically fills in via normal nav functionality). So I'm now at the point where when any line is selected I want to call a function in the item page to set the line no... This also causes me many issues as I'd like to simply call the function from the page, but it calls the function of another item list instance (since I just made a variable of type page - subtype: item page). So another thought would be to get the correct instance but that also gives me issues as you cannot re-set a page variable in code (/assignment of this variable is not allowed/). 

So.. I have it so there is a function in the card page which passes the item page instance to the line subpage which passes the selected line rec by calling the function of the passed argument. The issue with this is I need to call the card page function from the line subpage after selecting a record, but how can I get the correct card page instance to accomplish this? It would be nice to just call a function to set the instance to some variable but it doesn't seem possible, and even calling a getter function to get the instance doesn't seem possible....
 
Sorry this was so much, please help..
Thanks
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 75,802 Super User 2024 Season 2 on at
    Passing variables between subpages
    Hi, you can refer to the Sales Header and Sales Line on the Sales Order page.
    If you need to transfer variables to other pages, you need to create functions on other pages.
    Here is a simple example, I hope it can give you some hints.
     
    Thanks.
    ZHU
  • Jaden Kuhn Profile Picture
    Jaden Kuhn 25 on at
    Passing variables between subpages
    Well this technically is not an answer to my passing variables problem, but I found out the solution to my actual issue. I did not realize that the primary key(s) of the subforms need to contain the same primary keys of the parent. So originally I just had the primary key of my item table (not the actual nav item table) just as an entry no. But now I also included the line no. and header no. too. 
     
  • Jaden Kuhn Profile Picture
    Jaden Kuhn 25 on at
    Passing variables between subpages
    Hopefully all of that made sense^

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,433 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans