Re: [rcrofoot] Execute php code on record save...
Hi Rick,
If you haven't purchased a plugin before, you can sign up for a username/password and you would then have access to the free plugins.
Here is an overview of what you need in a plugin. First, you need a plugin header at the top of the file like this:
You can fill out this information with whatever you want.
After that, you need to add an action on the record_save hook. It would look something like this:
addAction('record_postsave', '_pluginName_myFunctionName', null, 4);
You will change "_pluginName_myFunctionName" with the name of your function. We usually put the name of the plugin in the function name to avoid function name collisions. For example, if you plugin was called duplicateRecords and your function copied a record, you could use a function name like this:
_duplicateRecords_copyRecord
Finally, you need to actually define and code your function. Your function definition would look something like this:
function _pluginName_myFunctionName($tablename,
$isNewRecord, $oldRecord, $recordNum) {
}
You would put the code you want to execute after a record is saved in here. Note that this function will be called after ANY record is saved, so you'll probably want to put in some code that will only execute if the record is in a certain table.
Hope this helps get you started.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/