19.01.2023, 11:45
(This post was last modified: 19.01.2023, 11:56 by dave.bolas@se.com.)
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
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