Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access to local variables and functions in table and pageextension #593

Closed
FSharpCSharp opened this issue Sep 4, 2017 · 18 comments
Closed

Access to local variables and functions in table and pageextension #593

FSharpCSharp opened this issue Sep 4, 2017 · 18 comments

Comments

@FSharpCSharp
Copy link

@FSharpCSharp FSharpCSharp commented Sep 4, 2017

When creating a TableExtension and/or PageExtension it would be useful to be able to call the local functions of the original object. This would also come close to the concepts of inheritance. You could also address the inherited object with Base.XYZ to call the function. In this case, it would also make sense to access the global variables in this object.

@FSharpCSharp FSharpCSharp changed the title Access to local variables in table and pageextension Access to local variables and functions in table and pageextension Sep 4, 2017
@Gallimathias

This comment has been minimized.

Copy link
Contributor

@Gallimathias Gallimathias commented Sep 4, 2017

This definitely belongs to: #153, #120, #186

@FSharpCSharp

This comment has been minimized.

Copy link
Author

@FSharpCSharp FSharpCSharp commented Sep 5, 2017

True, there were already points that had similar requirements. But our requirement in this case was rather an approach known from the object-oriented world. This was not primarily a matter of overwriting existing functions, as described in the other topics. It is much more about accessing existing logic of a page or table. Of course, this is a certain danger, because you have to assume that the actual object changes only slightly from month to month. It would be an improvement if, for example, when creating NAV events, the "sender" would always be transferred by default. Then you could easily access the original object and use its public functions.

@Gallimathias

This comment has been minimized.

Copy link
Contributor

@Gallimathias Gallimathias commented Sep 6, 2017

That's why I linked them. It's a package for me.

I still see a lot of problems with competing code in general. As I see it, we use the syntax "extension everywhere" from c# 8. I haven't checked yet whether this works in the background.

Bottom line, I think it's cool but the current style and wise also in my eyes a little bit dirty. I really would like to see a clear inheritance structure.

Topics that need to be clarified are, in my opinion:

  • Handling and compatibility with original code
  • Access to "original" methods
  • Dealing with competing code
  • Time of execution
  • Error and conflict handling
@Gallimathias

This comment has been minimized.

Copy link
Contributor

@Gallimathias Gallimathias commented Sep 7, 2017

What about competing apps? For example, an app sets the customer's name to invisible and another app to visible?

Which app wins? Can I control this behavior? When I try to add the field manually, nav Crashs?

I'm adding this because I think it's the same topic or it has the same consequences.

@StanislawStempin

This comment has been minimized.

Copy link

@StanislawStempin StanislawStempin commented Sep 8, 2017

We don't foresee allowing access to local variables/procedures. However, something we are considering longer-term is introduction of protected visibility. It will require base app refactoring before it can be used in extensions though.

@ajkauffmann

This comment has been minimized.

Copy link
Contributor

@ajkauffmann ajkauffmann commented Mar 24, 2018

I would like to express my support to the idea that tableextensions and pageextensions do have access to local variables and functions. I'm not talking about inheritance or any calling code with Base.SomeFunction.
Instead, I'm thinking like this: from the code in a tableextension you can directly access fields on the record, without the need of using Rec.SomeField. From that point of view, a tableextension is getting closer to a table then a variable of type Record. Enabling a tableextension to call all functions, including the local functions, makes it even more closer to the original table.
For example, I have seen scenario's where I need functions like CalcBaseQty or CalcUnitCost in a tableextension for table Sales Lines. Which is not possible because those functions are local. But I can call them when I add code to the base table. So why not when writing code in a tableextension?

@MicAlter31

This comment has been minimized.

Copy link

@MicAlter31 MicAlter31 commented Mar 24, 2018

I totally agree with Arend-Jan. Have a look at Sales Order Subform and try to validate the field „No.“ and compare the results. There are several (page) local functions which are called (e.g. OnAfterValidateNo or OnAfterValidateQty). I think that code cloning is not the right way - remember that the code could be changed with every CU.

The best solution would be to have full access to the object when implementing a page or table extension. The easiest to declared them like some others as „external“ ;)

@rdiazbla

This comment has been minimized.

Copy link

@rdiazbla rdiazbla commented Jun 11, 2018

Hi,
I have wrote in issue #2421 and Gallimathias (thanks) redirect me to this issue, but I don't find there the solution.

I add a new procedure (personalization) in a tableextension because the original procedure is internal, and I not have acces to global variables defines in the table.

In this example I can declare local variables but not always is the solution. Is posible, using AL, access to global variables?

tableextension

@ligoendeavor

This comment has been minimized.

Copy link

@ligoendeavor ligoendeavor commented Dec 18, 2018

Facing the same problem. I want to be able to change the "Ship-to" field (ShipToOptions) to "Custom Address" in the Sales Order page. This is a global variable in the page. Is it even possible to change the value in this field from an extension?

@stephanweidmann

This comment has been minimized.

Copy link

@stephanweidmann stephanweidmann commented Mar 8, 2019

If a Publisher in the main page is giving Access to "globalvar" by a new Publisher, can a subscriber subscribe to a global Variable, which is only introduced in the page extensions?

Example:
Resource Availability lines.
The Task is to reduce the capacity by absences, and calculate the net availability with this reduced capacity.
There is a Publisher now which allows GlobalVar Access. But you only can subscribe in a codeunit, and there you cannot add new columns to the page (Absence, Netavailability).
This must be done in the page Extension - but the calculation can only be made with Access to global vars (Else, you cannot now if the amounts should be shown as "From XY to XY (Net Change) or until XY (Balance).

@fvet

This comment has been minimized.

Copy link

@fvet fvet commented Apr 19, 2019

@atoader Can we have any insights on the status / planned solution for this issue? Trying to prepare the AL journey, we have to put lots of PageExtensions (that are mainly extending the editable / visibility property) on hold due the inaccessibility of page Globals. Don't know if there's a valid workaround?

image

@meilel

This comment has been minimized.

Copy link

@meilel meilel commented Apr 24, 2019

@atoader An update on the status of this issue would be helpful. I have to use the UpdateCust() function from the Job Table in my Table Ext,

@atoader

This comment has been minimized.

Copy link
Member

@atoader atoader commented Apr 25, 2019

@fvet @meilel we appreciate the feedback very much! I don't think this feature will make it in for the Fall release because our backlog is filled with other high priority, high value features. I would like to encourage you to post this to our Ideas forum at https://aka.ms/BusinessCentralideas, or vote up the idea if its already there.
This will help us a lot in prioritizing this feature for a future release.

@fvet

This comment has been minimized.

Copy link

@fvet fvet commented Apr 25, 2019

Let's move the 22 votes from the past 1.5 year of this topic to 'ideas' and 👍
https://experience.dynamics.com/ideas/idea/?ideaid=8aa70fdb-2b67-e911-b047-0003ff688f4c

@atoader atoader added this to the October 2019 milestone Aug 8, 2019
@carlosyuwono

This comment has been minimized.

Copy link

@carlosyuwono carlosyuwono commented Aug 13, 2019

I am creating a page ext for "Item Tracking Lines" page, but I just found out that none of the temp variable is accessible. Is this feature still on track for Oct 2019 release?

@SteveKrisjanovsD365

This comment has been minimized.

Copy link

@SteveKrisjanovsD365 SteveKrisjanovsD365 commented Sep 19, 2019

@carlosyuwono I'm following this one too. I just encountered the same issue as you with the same page you cited.

Any status update from Microsoft on this enhancement being ready for Oct 2019 wave 2?

@atoader

This comment has been minimized.

Copy link
Member

@atoader atoader commented Sep 21, 2019

Hi! This will be available in the wave 2 2019 release. Any issue marked with the October milestone will be delivered with this release

@umang11

This comment has been minimized.

Copy link

@umang11 umang11 commented Dec 23, 2019

i still can not access the global variable totalsalesline of page sales order subform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.