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.
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.
Try to pass the ControlAdding to the Piblication/Suscription as var and you will manage to achieve it
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
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,151 Super User 2024 Season 2
Martin Dráb 229,993 Most Valuable Professional
nmaenpaa 101,156