Skip to main content
added 1012 characters in body
Source Link
SFDC_BigDog
  • 795
  • 4
  • 19
  • 40

Updated Answer:

{!REQUIRESCRIPT("/support/console/38.0/integration.js")} 
{!REQUIRESCRIPT("/soap/ajax/38.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/38.0/apex.js")} 


    var outboundFaxActivityId = '{!Outbound_Fax__c.Activity_ID_Developer_Use__c}'; 
    console.log(outboundFaxActivityId); 

    if(outboundFaxActivityId.size()> 0) { 
      if(typeof(srcUp) == 'function') //Checks that it is in console 
      { 
       var openSubtab = function(result){ 
       sforce.console.openSubtab(result.id,'/{!Outbound_Fax__c.Activity_ID_Developer_Use__c}', true, 'Fax', null);
       }; 
       sforce.console.getEnclosingPrimaryTabId(openSubtab); 

      } 
      else{ 
       window.parent.location.href=('/{!Outbound_Fax__c.Activity_ID_Developer_Use__c}') 
      } 
   } 
   else { 
     alert('There is no Activity record associated with this Fax. Please contact your System Adinistrator'); 
   }

Updated Answer:

{!REQUIRESCRIPT("/support/console/38.0/integration.js")} 
{!REQUIRESCRIPT("/soap/ajax/38.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/38.0/apex.js")} 


    var outboundFaxActivityId = '{!Outbound_Fax__c.Activity_ID_Developer_Use__c}'; 
    console.log(outboundFaxActivityId); 

    if(outboundFaxActivityId.size()> 0) { 
      if(typeof(srcUp) == 'function') //Checks that it is in console 
      { 
       var openSubtab = function(result){ 
       sforce.console.openSubtab(result.id,'/{!Outbound_Fax__c.Activity_ID_Developer_Use__c}', true, 'Fax', null);
       }; 
       sforce.console.getEnclosingPrimaryTabId(openSubtab); 

      } 
      else{ 
       window.parent.location.href=('/{!Outbound_Fax__c.Activity_ID_Developer_Use__c}') 
      } 
   } 
   else { 
     alert('There is no Activity record associated with this Fax. Please contact your System Adinistrator'); 
   }
deleted 9 characters in body
Source Link
Santanu Boral
  • 36.2k
  • 8
  • 45
  • 72

I have a custom javascript button which has to check for a value in custom field on an object record and has to perform the functionality. In this case, if the field value is not null, it has to redirect to a page (Both in console view and in normal view). It works well for the positive condition. The "Else" condition is not working. Instead of throwing error to the user, it is taking them to Salesfore home page in both console view and standard view. Please see the code and let me know if there is any issue in this.

    {!REQUIRESCRIPT("/support/console/38.0/integration.js")} 
    {!REQUIRESCRIPT("/soap/ajax/38.0/connection.js")} 
    {!REQUIRESCRIPT("/soap/ajax/38.0/apex.js")} 


    var outboundFaxActivityId = '{!Outbound_Fax__c.Activity_ID_Developer_Use__c}'; 
    console.log(outboundFaxActivityId); 

    if(outboundFaxActivityId != null) { 
      if(typeof(srcUp) == 'function') //Checks that it is in console 
      { 
       var openSubtab = function(result){ 
       sforce.console.openSubtab(result.id,'/{!Outbound_Fax__c.Activity_ID_Developer_Use__c}', true, 'Fax', null);
       }; 
       sforce.console.getEnclosingPrimaryTabId(openSubtab); 

      } 
      else{ 
       window.parent.location.href=('/{!Outbound_Fax__c.Activity_ID_Developer_Use__c}') 
      } 
   } 
   else { 
     throw new Error('There is no Activity record associated with this Fax. Please contact your System Adinistrator'); 
   }

I have a custom javascript button which has to check for a value in custom field on an object record and has to perform the functionality. In this case, if the field value is not null, it has to redirect to a page (Both in console view and in normal view). It works well for the positive condition. The "Else" condition is not working. Instead of throwing error to the user, it is taking them to Salesfore home page in both console view and standard view. Please see the code and let me know if there is any issue in this.

    {!REQUIRESCRIPT("/support/console/38.0/integration.js")} 
    {!REQUIRESCRIPT("/soap/ajax/38.0/connection.js")} 
    {!REQUIRESCRIPT("/soap/ajax/38.0/apex.js")} 


    var outboundFaxActivityId = '{!Outbound_Fax__c.Activity_ID_Developer_Use__c}'; 
    console.log(outboundFaxActivityId); 

    if(outboundFaxActivityId != null) { 
      if(typeof(srcUp) == 'function') //Checks that it is in console 
      { 
       var openSubtab = function(result){ 
       sforce.console.openSubtab(result.id,'/{!Outbound_Fax__c.Activity_ID_Developer_Use__c}', true, 'Fax', null);
       }; 
       sforce.console.getEnclosingPrimaryTabId(openSubtab); 

      } 
      else{ 
       window.parent.location.href=('/{!Outbound_Fax__c.Activity_ID_Developer_Use__c}') 
      } 
   } 
   else { 
     throw new Error('There is no Activity record associated with this Fax. Please contact your System Adinistrator'); 
   }

I have a custom javascript button which has to check for a value in custom field on an object record and has to perform the functionality. In this case, if the field value is not null, it has to redirect to a page (Both in console view and in normal view). It works well for the positive condition. The "Else" condition is not working. Instead of throwing error to the user, it is taking them to Salesfore home page in both console view and standard view. Please see the code and let me know if there is any issue in this.

{!REQUIRESCRIPT("/support/console/38.0/integration.js")} 
{!REQUIRESCRIPT("/soap/ajax/38.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/38.0/apex.js")} 


    var outboundFaxActivityId = '{!Outbound_Fax__c.Activity_ID_Developer_Use__c}'; 
    console.log(outboundFaxActivityId); 

    if(outboundFaxActivityId != null) { 
      if(typeof(srcUp) == 'function') //Checks that it is in console 
      { 
       var openSubtab = function(result){ 
       sforce.console.openSubtab(result.id,'/{!Outbound_Fax__c.Activity_ID_Developer_Use__c}', true, 'Fax', null);
       }; 
       sforce.console.getEnclosingPrimaryTabId(openSubtab); 

      } 
      else{ 
       window.parent.location.href=('/{!Outbound_Fax__c.Activity_ID_Developer_Use__c}') 
      } 
   } 
   else { 
     throw new Error('There is no Activity record associated with this Fax. Please contact your System Adinistrator'); 
   }
edited tags
Link
SFDC_BigDog
  • 795
  • 4
  • 19
  • 40
Source Link
SFDC_BigDog
  • 795
  • 4
  • 19
  • 40
Loading