Hi all,
Something I've come across time and time again is where people are not sure if their Table Level Scripts are being executed. It's difficult to see where you went wrong on your table level script if you're not even sure whether it has been executed or not. Furthermore if you have an integrated system and you expect a table level script to be fired after a sync has been run, when nothing happens you may not know whether that script was executed.
Here's a simple table level script that can be added to any entity and it will write the text out to the SQL log files if the script has been executed. It's also a pretty useful learning tool if your trying to work out when each of the TLS functions are called.
// Table level script will log all events to the SQL logs
function log(message, error) {try{CRM.CreateQueryObj('/* '+((error)?message:message+' */')).SelectSql();}catch(e){}}
function InsertRecord() { log("InsertRecord called",1); }
function PostInsertRecord() { log("PostInsertRecord called",1); }
function UpdateRecord() { log("UpdateRecord called. WHERECLAUSE=" + WHERECLAUSE,1); }
function DeleteRecord() { log("DeleteRecord called. WHERECLAUSE=" + WHERECLAUSE,1); }
Hope it's useful!