Custom Button clicks count:
There is custom button or link ,when click the button ,it will open the visual force page and count the how many times that button got clicked.
OnClick JavaScript {!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
try{
var clickCntStr = '{!opportunity.Number1__c}';
clickCntStr = clickCntStr == null || clickCntStr == "" ? "0" : clickCntStr;
clickCnt = parseFloat(clickCntStr);
++clickCnt;
// alert(clickCnt);
var updOpp = new sforce.SObject('opportunity');
updOpp.Id = "{!opportunity.Id}";
updOpp.number1__c= clickCnt;
//alert(updOpp.number1__c);
var result = sforce.connection.update([updOpp]);
}
catch(ccex){
console.log('click count increment error: ' + ccex);
}
window.open('/apex/Countbuttonclickpage?Id={!opportunity.Id}');
Visual force page:Countbuttonclickpage
<apex:page standardController="opportunity" >
<apex:form >
<apex:outputLabel value="Count of buttton click: {!opportunity.Number1__c}"></apex:outputLabel>
</apex:form>
</apex:page>
OnClick JavaScript | {!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} try{ var clickCntStr = '{!opportunity.Number1__c}'; clickCntStr = clickCntStr == null || clickCntStr == "" ? "0" : clickCntStr; clickCnt = parseFloat(clickCntStr); ++clickCnt; // alert(clickCnt); var updOpp = new sforce.SObject('opportunity'); updOpp.Id = "{!opportunity.Id}"; updOpp.number1__c= clickCnt; //alert(updOpp.number1__c); var result = sforce.connection.update([updOpp]); } catch(ccex){ console.log('click count increment error: ' + ccex); } window.open('/apex/Countbuttonclickpage?Id={!opportunity.Id}'); |
<apex:page standardController="opportunity" >
<apex:form >
<apex:outputLabel value="Count of buttton click: {!opportunity.Number1__c}"></apex:outputLabel>
</apex:form>
</apex:page>
No comments:
Post a Comment