+ Start a Discussion
Saikiran KolliSaikiran Kolli 

Unable to get beep sound after getting error message

public pagereference refresh()
    {
       if(SelectedBox=='' || SelectedBox==null || SelectedBox=='--None--')
       {
       
           ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please select Box to save'));
     
       }  
       
     else   
       if(WrapperMap.containsKey(reccode) && WrapperMap.get(reccode).OrdlItem.Quantity__c >=WrapperMap.get(reccode).OrdlItem.Supplied_Quantity__c)
       {
                if(WrapperMap.get(reccode).OrdlItem.Quantity__c == WrapperMap.get(reccode).OrdlItem.Supplied_Quantity__c){   
                          ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'supplied quantity exceeded'));
                
                    PageReference sound = new PageReference('/apex/sound');
                    sound.setRedirect(false);   
                    
                }
                else
                    WrapperMap.get(reccode).OrdlItem.Supplied_Quantity__c+=1; 
                   
                    
                if(changedItemIds.add(WrapperMap.get(reccode).OrdlItem.Id))
                {
                    Order_Line_Items__c Ordlt=WrapperMap.get(reccode).OrdlItem;
                      Ordlt.Select_Box__c = SelectedBox;
                     UpdatedOrderLineItem.add(Ordlt);  
                     ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Confirm,'Quantity Added'));
                    
                    
                }
        }
       else
          ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'item not matched')); 
      
 PageReference sound = new PageReference('/apex/sound');
  sound.setRedirect(false);
  return null;
    }

 
Alex SelwynAlex Selwyn
Not sure if I understand your question, but should the PageReference object be returned?
Saikiran KolliSaikiran Kolli
After displaying error message sound must be produced, So I created a new page . When I open that page I'm getting beep sound.
My secnairo is it should be in the same page after getting beep sound. 
Alex SelwynAlex Selwyn
Paste your sound vf and the main vf, if you can.
Saikiran KolliSaikiran Kolli
<apex:page controller="OrderFulfill" sidebar="false" id="page" tabStyle="Orders__c">

  <html>

<title>Print Test Page</title>

 <style type="text/css">
   .outBorder {
    border:3px outset black;
   }
   .inBorder{
    border-top:2px inset black;
    border-left:2px inset black;
   }
    
  </style>
<script>

function printDiv(divId) 
{
       var result = document.getElementById('page:form:pb1:pbstbl:pbsi:sl').value;
        if (result == "--None--") 
            {
                alert("Please Select Box");
            }
            else{
  
        window.frames["print_frame"].document.body.innerHTML=document.getElementById(divId).innerHTML;
        window.frames["print_frame"].window.focus();
        window.frames["print_frame"].window.print();
        }      
  }  
</script>

<body>

</body>


    <script src="{!URLFOR($Resource.jQuery,'')}"/>
    <script type="text/javascript">
       var j$ = jQuery.noConflict();
       
      
           function focusme()
           {
               var inpele = j$("input[id$='xyz']");
               inpele.val("");
               inpele.focus();
           }
       
    </script>
    

  
    <apex:outputPanel id="errorpanel">
    <apex:pageMessages id="showMsg" />
    </apex:outputPanel>
    <apex:form id="form">
        <apex:pageBlock title="OrderFulfill" id="pb1" >
            <apex:outputpanel id="panel">
            
                <apex:pageBlockSection columns="1">
                
                   <apex:pageBlockSectionItem >
                        <apex:outputLabel >Choose Box to Save</apex:outputLabel>
                <apex:selectList value="{!SelectedBox}" size="1">
                    <apex:selectOptions value="{!Boxoptions}"></apex:selectOptions>
                </apex:selectList>        
                    </apex:pageBlockSectionItem>
       
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="QR Code"/>
                    <apex:inputText value="{!reccode}" id="xyz" >
                        <apex:actionSupport event="onchange" action="{!refresh}"  reRender="pbstbl,xyz,errorpanel,pb1" oncomplete="focusme();"></apex:actionSupport>
                    </apex:inputText>
                </apex:pageBlockSectionItem>
             </apex:pageBlockSection>
                
            </apex:outputpanel>
            
            <apex:pageBlockSection columns="1" >
                 <apex:outputField value="{!order[0].name}"/>
                 <apex:outputField value="{!order[0].Location__c}"   />
                  
           <!-- </apex:pageBlockSection>
            <apex:pageBlockSection id="pbstbl" columns="1">
            <apex:pageBlockSectionItem id="pbsi">
        <apex:outputLabel >Choose Box to Print</apex:outputLabel>
        <apex:selectList value="{!PSelectedBox}" size="1" id="sl">
        <apex:selectOptions value="{!PBoxoptions}" id="so"></apex:selectOptions>
            <apex:actionSupport event="onchange" action="{!refreshme}" reRender="tblpnl, showMsg"/>
        </apex:selectList>
          
    </apex:pageBlockSectionItem> -->
          
     <br/>

      
    <apex:outputPanel id="tblpnl">
    <div id="itemsDiv">
   
    <apex:dataTable value="{!orderItemsList}" border="1" var="ord" id="theTable" rowClasses="odd,even" styleclass="outBorder" width="550px" rendered="{!orderItemsList.size>0}">
    
    
  

          <apex:column styleclass="inBorder">
             <apex:facet name="header">Subject</apex:facet>
              <apex:outputText value="{!ord.Name}"/>
         </apex:column>
        
        <apex:column styleclass="inBorder">
              <apex:facet name="header">Quantity</apex:facet>
              <apex:outputText value="{!ord.Quantity__c}"/>
        </apex:column>
        <apex:column styleclass="inBorder" >
            <apex:facet name="header">Supplied Quantity</apex:facet>
            <apex:outputText value="{!ord.Supplied_Quantity__c}"/>
        </apex:column>
    
        <apex:column styleclass="inBorder">
            <apex:facet name="header">Box Number</apex:facet>
            <apex:outputText value="{!ord.Select_Box__c}" />
        </apex:column>

    </apex:dataTable>
 
  
</div>
</apex:outputPanel>
<iframe name="print_frame" width="0" height="0" frameborder="0" src="about:blank"></iframe>

    
                <apex:pageBlockTable value="{!ListItem}" var="i">
                    <apex:column headerValue="Qrcode">
                        <apex:outputText value="{!i.qrcode}"></apex:outputText>
                    </apex:column>
                    <apex:column headerValue="Order Lineitemnames">
                        <apex:outputField value="{!i.OrdlItem.name}" />
                    </apex:column>
                  
                    <apex:column headerValue="Quantity">
                        <apex:outputField value="{!i.OrdlItem.Quantity__c}"  />
                        
                    </apex:column>
 
                    <apex:column headerValue="Supplied Quantity">
                    
                  
                            <apex:outputText value="{!i.OrdlItem.Supplied_Quantity__c}"  >
                   
                   
                  </apex:outputtext>

                    </apex:column>
  
                    
                  
                </apex:pageBlockTable>
                
                

            </apex:pageBlockSection>
        
            <apex:pageBlockButtons location="top" >
           <apex:commandButton value="Save" action="{!updateme}" id="saveButton"/> 

            
           </apex:pageBlockButtons> 
        </apex:pageBlock>
    </apex:form>
    </html>
</apex:page>
 
<apex:page controller="soundredirect" tabStyle="Orders__c">
<apex:form >


<script>
var playSound = (function beep() {
    var snd = new Audio("data:audio/wav;base64,//uQRAAAAWMSLwUIYAAsYkXgoQwAEaYLWfkWgAI0wWs/ItAAAGDgYtAgAyN+QWaAAihwMWm4G8QQRDiMcCBcH3Cc+CDv/7xA4Tvh9Rz/y8QADBwMWgQAZG/ILNAARQ4GLTcDeIIIhxGOBAuD7hOfBB3/94gcJ3w+o5/5eIAIAAAVwWgQAVQ2ORaIQwEMAJiDg95G4nQL7mQVWI6GwRcfsZAcsKkJvxgxEjzFUgfHoSQ9Qq7KNwqHwuB13MA4a1q/DmBrHgPcmjiGoh//EwC5nGPEmS4RcfkVKOhJf+WOgoxJclFz3kgn//dBA+ya1GhurNn8zb//9NNutNuhz31f////9vt///z+IdAEAAAK4LQIAKobHItEIYCGAExBwe8jcToF9zIKrEdDYIuP2MgOWFSE34wYiR5iqQPj0JIeoVdlG4VD4XA67mAcNa1fhzA1jwHuTRxDUQ//iYBczjHiTJcIuPyKlHQkv/LHQUYkuSi57yQT//uggfZNajQ3Vmz+Zt//+mm3Wm3Q576v////+32///5/EOgAAADVghQAAAAA//uQZAUAB1WI0PZugAAAAAoQwAAAEk3nRd2qAAAAACiDgAAAAAAABCqEEQRLCgwpBGMlJkIz8jKhGvj4k6jzRnqasNKIeoh5gI7BJaC1A1AoNBjJgbyApVS4IDlZgDU5WUAxEKDNmmALHzZp0Fkz1FMTmGFl1FMEyodIavcCAUHDWrKAIA4aa2oCgILEBupZgHvAhEBcZ6joQBxS76AgccrFlczBvKLC0QI2cBoCFvfTDAo7eoOQInqDPBtvrDEZBNYN5xwNwxQRfw8ZQ5wQVLvO8OYU+mHvFLlDh05Mdg7BT6YrRPpCBznMB2r//xKJjyyOh+cImr2/4doscwD6neZjuZR4AgAABYAAAABy1xcdQtxYBYYZdifkUDgzzXaXn98Z0oi9ILU5mBjFANmRwlVJ3/6jYDAmxaiDG3/6xjQQCCKkRb/6kg/wW+kSJ5//rL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z58uUNnryq6kt5RzOCkPWlVqVX2a/EEBUdU1KrXLf40GoiiFXK///qpoiDXrOgqDR38JB0bw7SoL+ZB9o1RCkQjQ2CBYZKd/+VJxZRRZlqSkKiws0WFxUyCwsKiMy7hUVFhIaCrNQsKkTIsLivwKKigsj8XYlwt/WKi2N4d//uQRCSAAjURNIHpMZBGYiaQPSYyAAABLAAAAAAAACWAAAAApUF/Mg+0aohSIRobBAsMlO//Kk4soosy1JSFRYWaLC4qZBYWFRGZdwqKiwkNBVmoWFSJkWFxX4FFRQWR+LsS4W/rFRb/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////VEFHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAU291bmRib3kuZGUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMjAwNGh0dHA6Ly93d3cuc291bmRib3kuZGUAAAAAAAAAACU=");  
    return function() {     
        snd.play(); 
    }
})();


playSound();

</script>


</apex:form>
</apex:page>
 
public with sharing class OrderFulfill {

public void sound()
{
      PageReference sound = new PageReference('/apex/sound');
      sound.setRedirect(false);
      
}


public string sound{get;set;}
    
public void SaveMe() 
    
    {
    
        olid=apexPages.currentPage().getParameters().get('id');
        
         olit = [select id, name, Order__c, Quantity__c,Supplied_Quantity__c,Difference__c,Compare__c, Type__c from Order_Line_Items__c where Order__c=:olid];
        for(Order_Line_Items__c o : olit)
        {
            System.debug('Hiii');  
            o.Supplied_Quantity__c =o.Supplied_Quantity__c;
            System.debug('Supplied_Quantity__c'+o.Supplied_Quantity__c);  

            UpdatedOrderLineItem1.add(o);
        }
        update UpdatedOrderLineItem1;
        
    }

    map<string, string> lineItemNameMapWithQrcode=new map<String, String>(); // lineitemname, qrcode
    list<Order_Line_Items__c> UpdatedOrderLineItem=new list<Order_Line_Items__c>();
    list<Order_Line_Items__c> UpdatedOrderLineItem1=new list<Order_Line_Items__c>();

    set<String> changedItemIds=new set<String>();
    set<String> lineItemName{Set;Get;}
    public String reccode{get;set;}
    public String SelectedBox{Set;Get;}
    public list<WrapOrderLineitemWithQrcode> lineitemlist{set;get;}
    public List<Orders__c> order {get;set;}    
    List < Order_Line_Items__c > list1;
    public list<SelectOption> Boxoptions{set;get;}
    Public list<Order_Line_Items__c> orderItemsList{Set;Get;}
    
    public String olid{get;set;}
    public List<Order_Line_Items__c> olit{get;set;}
    
    Map<String, WrapOrderLineitemWithQrcode> WrapperMap=new Map<String, WrapOrderLineitemWithQrcode>(); // string is qrcode    
 public String iframeSource { get; set; }
    
    public OrderFulfill()
    {
        Boxoptions=new list<SelectOption>();
        lineItemName=new set<String>();
        lineitemlist=new list<WrapOrderLineitemWithQrcode>();
        orderItemsList=new list<Order_Line_Items__c>();
        OrderLineItems();
        //lineItemNameMapWithQrcode=
        String boxnm='';
        Boxoptions.add(new SelectOption('--None--', '--None--'));
        for(integer i=1;i<=15;i++)
        {
            boxnm = 'Box '+i;
            Boxoptions.add(new SelectOption(boxnm, boxnm));
        }
       
    }
  
    public void OrderLineItems()
    {
    
        Set<id> oid = new Set<id>();
        List < Order_Line_Items__c > listOfItems = new List < Order_Line_Items__c > ();
        order = [SELECT name, Total_supplied_quantity__c, Location__c, From_Date__c, To_Date__c, id, Status__c, Submitted_On__c, SystemModstamp, Total_Quantity__c, Total_Units__c FROM Orders__c Where Id = : apexPages.currentPage().getParameters().get('id') ];
       
        for(Orders__c o : order)
        {
            oid.add(o.id);
        }
        
        /*list1 = [select id, name, Order__c, Quantity__c,Supplied_Quantity__c,Difference__c, Type__c from Order_Line_Items__c
        where Order__c = :order.id and Supplied_Quantity__c <= :0];*/
        list1 = [select id, name, Order__c, Quantity__c,Supplied_Quantity__c,Difference__c,Compare__c, Type__c from Order_Line_Items__c
        where Order__c IN :oid AND Compare__c = 'false' and Type__C = 'subject'];
       
        
        for (Order_Line_Items__c oli: list1) 
        {

            listOfItems.add(oli);
            lineItemName.add(oli.name);
            
        }
        for(QR_Codes__c qr: [Select Id, QR_Code__c,Name from Qr_Codes__c where name in: lineItemName])
        {
            lineItemNameMapWithQrcode.put(qr.name, qr.qr_code__c);
        }        
        for(Order_Line_Items__c oli: listOfItems)
        {
            if(lineItemNameMapWithQrcode.containskey(oli.name)) 
            {
                lineitemlist.add(new WrapOrderLineitemWithQrcode(lineItemNameMapWithQrcode.get(oli.name), oli));
                
            }
            
        }
        for(WrapOrderLineitemWithQrcode w: lineitemlist)
        {
            WrapperMap.put(w.qrcode, w);
        }
    }
    
    public list<WrapOrderLineitemWithQrcode> getListItem()
    {
        return WrapperMap.values();
    }
    public pagereference refresh()
    {
         reccode='';
       if(SelectedBox=='' || SelectedBox==null || SelectedBox=='--None--')
       {
           
           ApexPages.addmessage(new apexPages.message(ApexPages.severity.ERROR,'Please select Box to save'));
     
       }  
       
     else   
       if(WrapperMap.containsKey(reccode) && WrapperMap.get(reccode).OrdlItem.Quantity__c >=WrapperMap.get(reccode).OrdlItem.Supplied_Quantity__c)
       {
                if(WrapperMap.get(reccode).OrdlItem.Quantity__c == WrapperMap.get(reccode).OrdlItem.Supplied_Quantity__c)
                
                {   
                   ApexPages.addmessage(new apexpages.message(Apexpages.severity.ERROR,'supplied quantity exceeded'));
                
                    PageReference sound = new PageReference('/apex/sound');
                    sound.setRedirect(false);   
                    
                }
                else
                    WrapperMap.get(reccode).OrdlItem.Supplied_Quantity__c+=1; 
                   
                    
                if(changedItemIds.add(WrapperMap.get(reccode).OrdlItem.Id))
                {
                    Order_Line_Items__c Ordlt=WrapperMap.get(reccode).OrdlItem;
                      Ordlt.Select_Box__c = SelectedBox;
                     UpdatedOrderLineItem.add(Ordlt);  
                     ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Confirm,'Quantity Added'));
                    
                    
                }
        }
       else
          ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'item not matched')); 
      
         PageReference sound = new PageReference('/apex/sound');
         sound.setRedirect(false);
         return sound;
    }
    
   
    public PageReference updateme()
    {
        //refreshme();
        
        if(UpdatedOrderLineItem.size()>0)
        {
            update UpdatedOrderLineItem;
            OrderLineItems();
           
        }
       return new Pagereference('/apex/orderView?id='+order[0].id).setredirect(true);
        //return null;
    }
    
    public class WrapOrderLineitemWithQrcode
    {
        public string qrCode{Set;Get;}
        public Order_Line_Items__c OrdlItem{Set;Get;}
        public WrapOrderLineitemWithQrcode(String qrCode, Order_Line_Items__c OrdlItem)
        {
            this.qrCode = qrCode;
            this.OrdlItem = OrdlItem;
        }
    }
    
}