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:
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}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.');
else
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;
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="https://opfocus.com/contact-us" 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: http://upload.wikimedia.org/wikipedia/commons/8/87/Purple_buttons_(3538662481).jpg