Updating a script - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Updating a script (/showthread.php?tid=4514) |
Updating a script - dave.bolas@se.com - 19.01.2023 Hi, I have would like to dynamically update a script from another script (so update an event handler script from a library as part of version control ) I've tried this: -- Version 1.0.7 Added function function addOrUpdateECGEventScript( data ) -- data is a table with the various script properties defined. -- check for duplicate script with the same name exists = script.get( data.name ) if exists ~= nil then log( data.name, 'Script exists, updating' ) data.id = exists.id -- get the scripting id db:update( 'scripting', data ) else log( data.name, 'Script does not exist' ) db:insert( 'scripting', data ) data.id = db:getlastautoid() end script.save( data, true ) script.reloadsingle( data ) end And whilst it does not generate any errors in the Error Log, it doesn't update the Scripting -> Event Based view. Is what I am trying to achieve possible (the idea is that the library will ensure that the event handler is up to date)? If so, what am I doing wrong? Is it the true parameter in the script.save? Regards Dave Not to bother, I fixed it by specifying a where clause in my update db:update( 'scripting', data, { id = exists.id } ) Thanks |