31.05.2023, 09:26
(This post was last modified: 31.05.2023, 10:02 by christian.hegland@caverion.com.)
(31.05.2023, 06:44)admin Wrote: Save all objects IDs with export enabled to storage:
Code:ids = db:getlist('SELECT id FROM objects WHERE export=1')
storage.set('export_ids', table.concat(ids, ','))
Restore from storage:
Code:ids = storage.get('export_ids')
if type(ids) == 'string' and #ids > 0 then
db:query('UPDATE objects SET export=1 WHERE id IN (' .. ids .. ')')
end
script.reloadbacnet()
Fantastic! Thank you very much
Would it also be possible to use the script to add a tag called (export)?
Then i could filter objects by the tag name
(31.05.2023, 09:26)christian.hegland@caverion.com Wrote:(31.05.2023, 06:44)admin Wrote: Save all objects IDs with export enabled to storage:
Code:ids = db:getlist('SELECT id FROM objects WHERE export=1')
storage.set('export_ids', table.concat(ids, ','))
Restore from storage:
Code:ids = storage.get('export_ids')
if type(ids) == 'string' and #ids > 0 then
db:query('UPDATE objects SET export=1 WHERE id IN (' .. ids .. ')')
end
script.reloadbacnet()
Fantastic! Thank you very much
Would it also be possible to use the script to add a tag called (export)?
Then i could filter objects by the tag name
RE: I think i solved it:
ids = db:getlist('SELECT id FROM objects WHERE export=1')
storage.set('export_ids', table.concat(ids, ','))
-- loop over the ids and add the 'export' tag
for _, id in pairs(ids) do
grp.addtags(id, 'export')
end
Best regards
Christian
Christian