0

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');
            }
        };
4

0

You must log in to answer this question.

Browse other questions tagged .