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...
Suggested Answer

Control addin event arguments

(1) ShareShare
ReportReport
Posted on by 28

Hi,

According documentation the arguments in events within control addin must belong to an array.

I can't understand how should this work with arguments. Here's my code:

AL:

trigger PreviewDocument(DocId: Text)

begin

    Message('Trigger PreviewDocument Invoked');

end;

 

AL Control Addin:

event PreviewDocument(DocId: Text);

 

Js
script: (this is where the button is added inside a loop) In here, i
tried without the brackets, with them and with and without question
marks.

 

Image

 

 

Image

document.querySelector('buttonPreview').addEventListener('click', previewDocumentFunction);

After inspect the page:

 

Image

 

Nothing happens after the click.

Any ideas?

I have the same question (0)
  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at
    Hi,
    To correctly pass the DocId as an array to the InvokeExtensibilityMethod, you need to ensure that the JavaScript function receives the DocId as a single value and then wraps it in an array when calling the extensibility method. Here's how you can adjust your code:
    function previewDocumentFunction(DocId) {
        Microsoft.Dynamics.NAV.InvokeExtensibilityMethod('PreviewDocument', [DocId]);
    }
    Update html
    <div id="buttonPreview">
        <button onclick="previewDocumentFunction('" + DocId + "')">Preview</button>
    </div>
    the event should fire correctly, and the DocId should be passed to the AL trigger
  • Suggested answer
    Gerardo Rentería García Profile Picture
    26,842 Most Valuable Professional on at
  • josalm Profile Picture
    28 on at
    @Nitin Verma thanks for your response.
     
    Unfortunately that gives me an error. I used this syntax and had the same negative result.
    I'm using the innerHtml property to add this divs as shown bellow
     
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    22,458 Super User 2026 Season 1 on at

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,024 Super User 2026 Season 1

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,024 Super User 2026 Season 1

#3
YUN ZHU Profile Picture

YUN ZHU 1,383 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans