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

Execute ControlAddIn Javascript when from Subcribed Event

(0) ShareShare
ReportReport
Posted on by 44

Hi,

Unsure is this is the correct forum to post dev questions. If not, please let me know and I will delete it.

I’m starting to look at developing custom extensions for my workplace.
I have a project where I need to play a sound when an error occurs in a 3rd party extension.

I’m able to create a controlAddIn and trigger the sound via Javascript by clicking on an navigation button using an action.

The problem I am facing is that I would like to trigger the sound after a certain event happens.

I subscribed to the correct event using the following code

codeunit 60102 "AudioFeedback"
{
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"CodeUnitName", 'ActualEvent', '', true, true)]
    local procedure CallJavascript()
    begin
        Message('Running')
        CurrPage.AudioFeedback.playAudio('positive');
    end;
}

By moving my procedure into an Event, I no longer have access to the page variable called CurrPage.

I understand why this doesn’t work but I can’t seem to find a way around it.
Can I either pass the CurrPage object to my procedure or should my procedure dispatch a new event that is captured by my page and then executes the code.

My apologies if I’m not using the correct terms. I know many languages but AL is bran new to me.

Thank you in advance for any help.

  • Suggested answer
    YUN ZHU Profile Picture
    103,797 Super User 2026 Season 2 on at

    Hi, As far as I know, you cannot access CurrPage in the event of Codeunit, for example, the standard Page.Update([Boolean]) Method cannot be used either.
    I think you can try to use Page Extension, don't use events, it may be possible to use the Trigger of the page.

    https://learn.microsoft.com/en-us/dynamics-nav/page-and-action-triggers

    Hope this helps.

    Thanks.

    ZHU

  • JJMc Profile Picture
    293 on at

    Try to pass the ControlAdding to the Piblication/Suscription as var and you will manage to achieve it

  • Steven F. Profile Picture
    44 on at

    Hi Yun,

    thanks for the reply. Unfortunately, the default page triggers are not suitable for my needs and I can't seem to bubble the event back to the page or pass it in a function as my technical skills for AL are still in beginner mode.

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

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 795 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 561 Super User 2026 Season 2

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 323 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans