How to referesh the primary tab in console after sending the email using custom button

I have a custom button in lead detail page which is used to send an email. After sending the email , i am updating the status from New to In progress. Everything is working fine. But after sending the email , i have to again manually refresh the tab to see the email sent in the activity history. it is not displaying it after click on send button in the email sending page. Here is the code of custom button.

{!REQUIRESCRIPT("/support/console/36.0/integration.js")}  {!REQUIRESCRIPT("/soap/ajax/36.0/connection.js")}  if(sforce.console.isInConsole()) { if ('{!Lead.OwnerId}' != '{!User.Id}'){ alert("{!$Label.SFA_SendEmail_NotAuthorized}"); }else if (('{!Lead.Brand__c}'=='RENAULT')){     if (('{!Lead.IsContactCallSucessfull__c}'==true))     {     sforce.console.getEnclosingPrimaryTabId(function (result) { sforce.console.openSubtab(result.id , '{!$Site.BaseUrl}/_ui/core/email/author/EmailAuthor?p2_lkid={!Lead.Id}&[email protected] &template_id={!$Label.PDQ_SuccessTemplate}',true,'',null); }); } else  { sforce.console.getEnclosingPrimaryTabId(function (result) { sforce.console.openSubtab(result.id , '{!$Site.BaseUrl}/_ui/core/email/author/EmailAuthor?p2_lkid={!Lead.Id}&[email protected] &template_id={!$Label.PDQ_FailureTemplate}',true,'',null); }); } } else if (('{!Lead.Brand__c}'=='DACIA' )){ if (('{!Lead.IsContactCallSucessfull__c}'==true))     {         sforce.console.getEnclosingPrimaryTabId(function (result) { sforce.console.openSubtab(result.id , '{!$Site.BaseUrl}/_ui/core/email/author/EmailAuthor?p2_lkid={!Lead.Id}&[email protected] &template_id={!$Label.PDQ_SuccessTemplate}',true,'',null); }); } else { sforce.console.getEnclosingPrimaryTabId(function (result) { sforce.console.openSubtab(result.id , '{!$Site.BaseUrl}/_ui/core/email/author/EmailAuthor?p2_lkid={!Lead.Id}&[email protected] &template_id={!$Label.PDQ_FailureTemplate}',true,'',null); }); } } } sforce.console.getFocusedPrimaryTabId(showTabId); var showTabId = function showTabId(result)          {             var tabId = result.id;             alert('Primary Tab IDs: primaryTabId ' + tabId );             sforce.console.refreshPrimaryTabById(tabId , true, refreshSuccess);         };          var refreshSuccess = function refreshSuccess(result)          {             //Report whether refreshing the primary tab was successful             if (result.success == true)              {                 alert('Primary tab refreshed successfully');             }              else              {                 alert('Primary did not refresh');             }         }; 

Replay

Category: javascript Time: 2016-07-29 Views: 0

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.228 (s). 12 q(s)