You need to sign in to do that
Don't have an account?
Subhodeep Dey 2
How to get last activity date of a custom button in a object
Hi,
I have a task assigned to get the last clicked and how many times it's clicked and clicked by whome for a custom button (Javascript) for any object.
You can try the following. From the code you posted, it seems like you have this button from the Opportunity object.
Please note that you will have to replace Click_Counter__c with the custom field you created to store the click counts.
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
try{
var clickCntStr = '{!Opportunity.Click_Counter__c}';
clickCntStr = clickCntStr == null || clickCntStr == "" ? "0" : clickCntStr;
clickCnt = parseFloat(clickCntStr);
++clickCnt;
var updOpp = new sforce.SObject("Opportunity");
updOpp.Id = '{!Opportunity.Id}';
updOpp.Click_Counter__c = clickCnt;
updOpp.LastActivityDate = Date.today();
var result = sforce.connection.update([updOpp]);
if(result[0].getBoolean("success")){
alert("update successful");
window.top.location.href = '/' + '{!Opportunity.Id}';
}
else{
alert("update error");
}
}
catch(ccex){
console.log('click count increment error: ' + ccex);
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi