function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
bozotheclownbozotheclown 

Forcing an Audible Sound from Apex?

Hello.  I have an ActionPoller that forces a refresh of a VF pageBlockTable every ten seconds.  I am hoping to add an audio alert to notify if the pageBlockTable changes upon refresh.  Are we able to do this via Apex?  In other words, is there any audio alert that I could use to note that a list size has changed?

 

Thanks in advance.

sfdcfoxsfdcfox

Here's how I would accomplish this:

 

1) Create a hidden field:

 

<apex:inputHidden value="{!hasUpdates}" id="hasUpdates"/>

 2) Modify your actionPoller to use onComplete:

 

<apex:actionPoller interval="10" reRender="form" action="{!getUpdates}" onComplete="processUpdates()" />

3) Include an appropriate element that can play an audio snippet (Flash is one possibility):

 

<object id="dingSWF" width="0" height="0" data="{!$Resource.dingSWF}" />

4) In a script tag somewhere, use the processUpdates function:

 

function processUpdates() {
  var updateFlag = document.getElementById('{!$Component.form.hasUpdates}')
  if(updateFlag.value=='true') {
    var dinger = document.getElementById('dinger')
    dinger.play()
  }
}

Note that this code is only hypothetical, as I've not actually had to manipulate a Flash from within JavaScript, but this should get you very close to where you'd like to go. It might also be able to simply hijack salesforce.com's default ding (the one that plays when you have a task reminder), but I wouldn't rely on their internal library too heavily.

bozotheclownbozotheclown

Thanks.  Much appreciated.