We need ability to add code in between existing code (similar to currently available feature to add a field after an existing field in page).
Please see example code below
IF ((Amount <= 0) AND ("Bank Payment Type" = "Bank Payment Type"::"Computer Check") AND "Check Printed") OR
((Amount < 0) AND ("Bank Payment Type" = "Bank Payment Type"::"Manual Check"))
THEN BEGIN
IF BankAcc."Currency Code" <> "Currency Code" THEN
ERROR(BankPaymentTypeMustNotBeFilledErr);
CASE "Bank Payment Type" OF
"Bank Payment Type"::"Computer Check":
BEGIN
TESTFIELD("Check Printed",TRUE);
CheckLedgEntry.LOCKTABLE;
CheckLedgEntry.RESET;
CheckLedgEntry.SETCURRENTKEY("Bank Account No.","Entry Status","Check No."); _//New AL Extension code_
CheckLedgEntry.SETRANGE("Bank Account No.","Account No.");
CheckLedgEntry.SETRANGE("Entry Status",CheckLedgEntry."Entry Status"::Printed);
CheckLedgEntry.SETRANGE("Check No.","Document No.");
IF CheckLedgEntry.FINDSET THEN
REPEAT
CheckLedgEntry2 := CheckLedgEntry;
CheckLedgEntry2."Entry Status" := CheckLedgEntry2."Entry Status"::Posted;
CheckLedgEntry2."Bank Account Ledger Entry No." := BankAccLedgEntry."Entry No.";
CheckLedgEntry2.MODIFY;
UNTIL CheckLedgEntry.NEXT = 0;
END;
"Bank Payment Type"::"Manual Check":
BEGIN
IF "Document No." = '' THEN
These features are crucial for converting our vertical into extension. I am sure vast majority of the solution center would require such ability as 90% of the code enhancement we do in a daily basis falls under this category. Without this feature we can not switch from C/SIDE to AL going forward.
Please note we do not want to do code cloning as it will put a high overhead in maintaining these extension and will defeat the purpose for extension, which is ease of upgradability and maintainability.
Hi @Rama-M, thank you for reporting the issue. I did not get an idea. Do you need that feature in VS Code? What are the use cases for that feature? Why can not we use Ctrl+R to find and replace required code?
Hi Andrey,
We need a feature to add your custom code to be inserted in between a block of standard code. We want this feature available through extension.
This similar feature as adding a custom field in a page after a standard field through extension. Hope this helps.
Hi Andrey,
We need a feature to add your custom code to be inserted in between a block of standard code. We want this feature available through extension.
This similar feature as adding a custom field in a page after a standard field through extension. Hope this helps.
I see what you mean, but I do not think we can do that. The standard objects are stored in the DB in the internal format and can not be changed directly, but only via extensions mechanism. Changing the standard objects could result in full rebuilding of W1 app, changing the tables and DB structure, and more important potentially losing the users data. It is not safe, so we can not allow extensions to change the system code uncontrollably.
I understand. But this is such a popular (90%) of any typical customer customization we do in the field. Can you escalate this to product development in Denmark to have a think. Without this the NAV world will suffer, given CSIDE is on it's way out in wich you could do such changes.
Further this feature is the success story behind Dynamics NAV. I am sure Microsoft will not want to loose this by really restricting what can be changed. We almost want a code flow of starting off with some standard code branch to extension code in any arbitrary point (not necessarily on event hooks) and to continue with rest of the standard code.
I am fully aware of requesting additional events and using events. This method will not address my request to put code any arbitrary point in the code. Events are normally defined on a logical trigger (ie on before... or on after).See my code example before.
The entire BC codebase is getting converted to AL, so you'll be able to put code wherever you like. Keeping in mind, that means it (very likely) cannot be deployed to AppSource, or potentially even as an App for other databases (expecting more info at Directions).
Without getting too much into designing solutions, a well placed event in the above code should let you achieve what you need.
If these kind of changes are not going to be supported in extension or AL code. I do not think Microsoft can scrap CSIDE. It is taking away a key customization feature and it be a disaster to Dynamic NAV industry.
In an OnPrem database, that should be possible with AL when C/AL is finally shoved down the drain.
From this point onwards, AL was announced to be usable for extensions as well as conventional coding.
But for SaaS deployment, currently no chance. Actually I asked for something like this (arbitrary code line inserts in standard objects, also exiting a function prematurely if necessary to prevent standard code from being executed to run your own instead) already in November 2017 in a feedback Session at the ISV Red Carpet Days in Lyngby. I understand why MS is not inclined to allow this, but it shows the limitations of extensions.
If your solution is horizontal, then you're better off building a solution app.
While allowing code at any line would be the ultimate in versatility, it's not a practical solution to implement.
Hooks and events are perfectly good patterns. In time there will be enough to cover all scenarios. The best thing you can do in the interim is provide event suggestions to help improve coverage.
Most helpful comment
You need to use events.
If you don't see an event handler which can manage your scenario, then you need to raise an event request here.