Skip to main content
Dynamics 365 Community / Forums / Finance forum / How to play a sound in...
Finance forum
Suggested answer

How to play a sound in D365

editSubscribe (0) ShareShare
ReportReport
Posted on by

I need to play a sound in certain conditions; i.e when an error or a warning is thrown.

Can I make that in Ax 365 ? 

 
the following code did not work. I belive the reason is that the code was executed on the server side instead of the client side, so I could not hear the sound. 
[ExtensionOf(formStr(WHSPack))]
final class REVClass_WHSPack_Extension
{
    /// <summary>
    /// MEC_EXT-00027_LandedCostChargesAutomation
    /// Peiqing Jia on 01/29/2023
    /// </summary>
    [FormControlEventHandler(formControlStr(WHSPack, ItemId), FormControlEventType::Modified)]
    public static void ChangeRequestedBy_OnClicked(FormControl sender, FormControlEventArgs e)
    {
        InventInventItemSearchResult result = inventItemSearch.search(this.valueStr());
                
        if (!result ||
            !result.parmItemId())
        {
            ret = checkFailed(/@WAX758/);
            
            System.Media.SoundPlayer YourMPlayer;
            YourMPlayer= new System.Media.SoundPlayer();
            YourMPlayer.set_SoundLocation(https://download01.fangcloud.com/download/a23675d5fba24dbf9d20b50efbf8e629/acfb0471b29cc9eb3bd0f2dd81482dc772eb8aaa36696b11eb50ef4070acae6f/Alarm03.wav/);
            YourMPlayer.Play();
        }
    }
}
Attachments
  • Andre Arnaud de Calavon Profile Picture
    Andre Arnaud de Cal... 283,126 Super User on at
    How to play a sound in D365
    Hi Peiqing,
     
    You got a valuable reply from Martin. Can you tell us what is the benefit and business value of playing a sound?
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 222,646 Super User on at
    How to play a sound in D365
    Moved from D365 general forum to the Finance forum, because it's clearly about F&O and not about D365 in general.
     
    You're right. The code can't work as you want because X++ us executed on server, not in a browser on client's machine.
     
    You'd have to use client-side JavaScript to do such a thing, which in F&O means creating an extensible control. But it doesn't sound to me like what you want to in this case.
     
    If you want to change the way how error and warning notifications work in F&O, you can also log it as an idea for Microsoft.

Helpful resources

Quick Links

New Blog Features Released!

Check out the new community blog features for viewers and authors…

Setting Up Knowledge Sources for Copilot…

Look at how configuring a comprehensive knowledge base is crucial…

Demystifying Copilot with Georg Glantschnig…

Industry experts answer burning questions directly from our amazing Community…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,126 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,646 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Featured topics

Product updates

Dynamics 365 release plans