I like to remove all DOM data (instances / history) but keep the definition from a test system.
What is the easiest way to do this? or can someone share a code snippet to run in an automation script?
Mieke Dryepondt [SLC] [DevOps Advocate] Selected answer as best 10th October 2023
If you are looking to do it yourself, this snippet will retrieve all instances in chunks and deletes them bit by bit, so the script doesn't timeout or run out of memory.
Deleting history should be as simple as replacing "domHelper.DomInstances" with "domHelper.DomInstanceHistory".
var domHelper = new DomHelper(engine.SendSLNetMessages, "mymodule"); PagingHelper<DomInstance> pagingHelper = domHelper.DomInstances.PreparePaging(new TRUEFilterElement<DomInstance>()); while (pagingHelper.MoveToNextPage()) { List<DomInstance> dataTypes = pagingHelper.GetCurrentPage(); foreach (DomInstance dataType in dataTypes) { try { domHelper.DomInstances.Delete(dataType); } catch (CrudFailedException e) { engine.GenerateInformation(e.ToString()); } } engine.KeepAlive(); }
Mieke Dryepondt [SLC] [DevOps Advocate] Selected answer as best 10th October 2023