How to Add Your Own OpFocus Sales Activity Tracker Button

How to Add Your Own Sales Activity Tracker ButtonIf you are currently using the OpFocus Sales Activity Tracker App on your Salesforce instance and would like to know how to add a new Sales Activity button to either the Contact or Lead Object, this blog will give you directions to accomplish that. If you haven’t used or even heard of the App, be sure to check it out here; it is a great way to track how many phone calls, voicemails, emails, and meetings it is taking your sales reps to close a deal.

In this example, I will use a new type called “IM”. First, you have to add a new type to the Type field in the Sales Activity Custom Object. If you want to add a new Sales Activity button on the Lead Object, then go to Customize > Lead > Buttons, Links, and Actions, and click “New Button or Link”. In the Custom or Link Edit page do the following:

  • Enter “IM” in Label and Name
  • Choose “Detail Page Button” for Display Type
  • Choose “Execute JavaScript” for Behavior
  • Copy and paste the following code to the formula box

 var objID = "{!Lead.Id}";
 var attemptType = "IM";
 var callerType = "Lead";
 var aID = "";
 var cID = "";

 var finishedLocation;

 if (window.parent.location.href=="/ui/desktop/DesktopPage") { 
 finishedLocation = '/{!Lead.Id}&isdtp=mn'; 
 } else { 
 finishedLocation = '/' + objID; 

 if (objID.length != 0) {

 // Make a synchronous call to Apex Web service method
 var result;
 var errorHappened = false;
 try {
 result = ''+sforce.apex.execute(
 "opfocus_sa.logAttempt", // Class
 "createSAT", // method
 {sAttemptType : attemptType,
 sCallerType : callerType,
 objectId : objID,
 accountId : aID,
 conId : cID});
 catch(err) {
 var errMessage = err.message;
 var nothing;
 if (errMessage == nothing)
 errMessage = err.faultstring;

 if (errMessage.indexOf('REQUEST_LIMIT_EXCEEDED') >= 0)
 alert('Error logging attempt: Total API request limit exceeded. Please contact your Administrator.');
 alert('Error logging attempt: ' + errMessage + 'nnPlease contact your Administrator.');
 errorHappened = true;

 // createSAT() returns null for success, error message for failure
 if (!errorHappened) {
 if (result != '') { 

 // Attempt creation failed; notify the user and return to the Lead record 
 alert("Error updating Lead. Please contact your Administrator.n" + result); 


 } else if (objID.length == 0) {

 alert("No Sales Activity Tracker created.");

 window.location = finishedLocation;
  • Save the button and put it on the page layout next to all the other Sales Activity Tracker buttons

IM button

 You can update the button code above to work on the Contact Object as well. Basically, you can replace all the “Lead”s with “Contact”s and change the line that has var aID = “”; to var aID = “{!Account.Id}”;

Currently, the App doesn’t allow for a new Sales Activity Type on the Opportunity Object, but we will launch a new Package with the ability to do so. Please stay tuned for the upgrade version.

Also, be sure to check out Top 5 Insider Tips: OpFocus Sales Activity Tracker for more useful tips and tricks when using the SAT.
[tagline_box backgroundcolor=”” shadow=”yes” shadowopacity=”0.1″ border=”1px” bordercolor=”” highlightposition=”left” link=”” linktarget=”_self” buttoncolor=”blue” button=”Contact Us” title=”Having trouble with the Sales Activity Tracker, or even just with Salesforce in general? Reach out to OpFocus!” animation_type=”slide” animation_direction=”left” animation_speed=”0.7″][/tagline_box]
Picture credit: