LUA Autoroute failed after some minutes

Hello everybody,
Im running this LUA:

function OnStoredInstance(instanceId, tags, metadata, origin)
if origin[‘RequestOrigin’] ~= ‘Lua’ then

– The tags to be replaced
local replace = {}
replace[‘StudyID’] = tags[‘AccessionNumber’]

– Modify the instance
local command = {}
command[‘Replace’] = replace
command[‘Remove’] = remove
local modified = RestApiPost(‘/instances/’ … instanceId … ‘/modify’, DumpJson(command, true))

– Delete the original instance
RestApiDelete(‘/instances/’ … instanceId)

– Upload the modified instance
RestApiPost(‘/instances/’, modified)

end
function OnStoredInstance(instanceId, tags, metadata)
SendToModality(instanceId, ‘DWAM’)
end
end

It works good but after some minutes or study it does not convert anymore
Im running Orthanc 19.3.1 with SQLite on Windows 10

Any idea?
Thanks a lot

Massimo

I correct, on the second store the LUA fails . Then if I restart the service the LUA runs good again

MP

Biotron spa

Hi,

You seem to have 2 OnStoredInstance functions nested → If I were you, I would first clean that and investigate afterwards.

HTH

Alain