Monday 24 July 2017

How to resolve the java script error "Cannot read property execute of undefined"

Hi All,

Debugging java script error is very tedious, if there is some still mistake then whole functionality will not work and it will not even tell line number of code where exactly that error is coming.

Anyways let us say you have custom detail page button (Source code = java script) , you want to call apex class from that button code, you faced this error "Cannot read property execute of undefined"
This is because you have missed to add {!requireScript("/soap/ajax/26.0/apex.js")} in the java script code.

{!REQUIRESCRIPT("/soap/ajax/23.0/connection.js")} 
{!requireScript("/soap/ajax/26.0/apex.js")} 

sforce.apex.execute("CaseApprovalController","unlockCaserecord",{caseid:'{!Case.Id}'});


No comments: