I have a visualforce page section in service cloud console, section has VF buttons which opens the PrimaryTab.
I want to auto close the newly opened PrimaryTab after 5 sec, is it possible add timer in console page?
here is my page will look like.
<apex:page standardController="contact" standardStylesheets="false" >
<script type="text/javascript">
function Refresh() {
sforce.console.openPrimaryTab(null, '/apex/RefreshPage?scontrolCaching=1&id={!contact.ID}', true,'Refresh', closeTab, 'Refresh');
}
function closeTab(result) {
if (result.success == true) {
var tabId = result.id;
sforce.console.closeTab(tabId);
}
else {
//alert('XXXX');
}
};
</script>
<apex:form id="myform" >
<apex:pageblock >
<apex:pageBlockButtons location="Top">
<apex:commandButton value="Refresh" onclick="Refresh();return false" styleClass="buttonStyle" style="background:LightBlue;width:60px;float:Center;" />
</apex:pageBlockButtons>
</apex:pageblock>
</apex:form>
setTimeout(function(){ alert("Hello"); }, 5000);
Obviously replacing the alert with the code you need?