web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Extend item template BC14 CU12

(0) ShareShare
ReportReport
Posted on by 30

I am trying to Extend the Item Template and we I look at the base app source code in both C/Side and AL(code) I see more parameters then the AL compiler is seeing?

Here is the integration event from C/side

[IntegrationEvent] OnAfterCreateFieldRefArray(VAR FieldRefArray : ARRAY [30] OF FieldRef;RecRef : RecordRef;VAR I : Integer)

Here is the code from AL

ItemTemplateGoToDefinition.png

but when I try to implement I so I can increment the array it is not valid:

[EventSubscriber(ObjectType::Table, Database::"Item Template", 'OnAfterCreateFieldRefArray', '', false, false)]
    local procedure HandleOnAfterCreateFieldRefArray(var FieldRefArray: array[30] of FieldRef; RecRef: RecordRef; var I: Integer)
    begin
        
    end;
The member referenced by event subscriber 'HandleOnAfterCreateFieldRefArray' parameter 'I' is not found.
Here is the screenshot.  I am not sure how to get past this error?

ItemTemplateOnAfterCreateFieldRefArray.png

  • Daniel Rimmelzwaan Profile Picture
    3,485 on at

    Have you tried using intellisense to add the parameters?

  • Daniel Rimmelzwaan Profile Picture
    3,485 on at

    What I mean to say is... sometimes I get weird errors like that. Sometimes AL has some difficulty loading references. What I try in those cases is recreate the subscriber and use intellisense. Sometimes closing VSCode and reopening helps too. Shouldn't but it does sometimes.

  • Mark Fielder Profile Picture
    30 on at

    Yes, It is not showing as a parameter in intellisense.  I am wondering if the generate symbols are out of sync after I applied CU 12 using a FOB.  So I am currently generating symbols using finsql.exe Command=generatesymbolreference.

    Thanks for the quick reply I will update the issue after the symbols are generated with an update.

  • Mark Fielder Profile Picture
    30 on at

    AfterGenerateSymbols.png

    After running generate symbols and restarting the service it worked as expected.  

  • Mark Fielder Profile Picture
    30 on at

    Well one step forward and a few steps backwards.   Before I started on this adventure today I saw that the item template table FieldRefArray length changed from 17 to 30 somewhere between BC14 initial release and CU12 so I thought that Microsoft had made extending the item template possible without a bunch of work.   However, the table triggers are still defining the array as [17] so it does not help that the procedures can handle [30].  So I get and error trying to add more fields into the array:( and I don't think BC has a way to grow an array?  System.CopyArray does not work.  I guess I will have to modify C/Side but I really wanted to use extensions for all changes for this customer. 

    trigger OnInsert()
    var
    FieldRefArray: array[17] of FieldRef;
    RecRef: RecordRef;
    begin
    TestField("Template Name");
    RecRef.GetTable(Rec);
    CreateFieldRefArray(FieldRefArray, RecRef);

    InsertConfigurationTemplateHeaderAndLines;
    end;

    trigger OnModify()
    var
    FieldRefArray: array[17] of FieldRef;
    RecRef: RecordRef;
    begin
    TestField(Code);
    TestField("Template Name");
    RecRef.GetTable(Rec);
    CreateFieldRefArray(FieldRefArray, RecRef);
    ConfigTemplateManagement.UpdateConfigTemplateAndLines(Code, "Template Name", DATABASE::Item, FieldRefArray);
    end;

  • Daniel Rimmelzwaan Profile Picture
    3,485 on at

    Did you doublecheck that you didnt miss the increase when you merged the CU? I've merged thousands of objects and this is typically the type of thing I would miss. If the CU objects don't include the array change, you might have caught a bug, those should have been modified to match the change in the event publisher. 

    Normally, if the event publisher changes, then ALL subscribers should change as well.

  • Mark Fielder Profile Picture
    30 on at

    It is not a merge problem and I validated that by checking the base app source from the docker image.   I also checked BC16 Spring 2020 and it also defines the array as [17] in the table triggers.  So this is a much bigger change in extensions vs legacy.    

  • Daniel Rimmelzwaan Profile Picture
    3,485 on at

    I would personally not jump to making this a larger problem, it's just a mismatched array dimension. Good catch :)

  • Mark Fielder Profile Picture
    30 on at

    I agree that it is not a large problem but it requires a base app change to the length of the array in a local variable in the following methods in C/Side or AL base app.  After the change in C/Side my extension now works but I think I am going to move all of the code to C/Side because I am worried how BC will handle the larger array without the fields mapped if I uninstall my extension.

    Table 1301 Item Template

    1) trigger OnInsert()

    2) trigger OnModify()

    3) procedure CreateConfigTemplateFromExistingItem(Item: Record Item; var TempItemTemplate: Record "Item Template" temporary)

    4) local procedure InsertConfigurationTemplateHeaderAndLines()

  • Verified answer
    Mark Fielder Profile Picture
    30 on at

    Well this was really educational.  I seems like the best solution is to extend array in legacy dev environment and add the fields in the extension and not worry about the array initialization error that occurs if the item template extension is not install.  If I try to make all the changes in legacy I run into a problem making the fields with the correct field no for the copies to work as mentioned in this thread's comments. andriwianto.wordpress.com/.../

    The extension gets around this problem because the extension is really a new table so it does not validate the field no's are accessible with a partner license.    

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 753 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 583 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 302 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans