Skip to content

Instantly share code, notes, and snippets.

@vkostyanetsky
Last active September 19, 2021 10:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vkostyanetsky/ca766fe281425953e0e2bbfe12fc70e2 to your computer and use it in GitHub Desktop.
Save vkostyanetsky/ca766fe281425953e0e2bbfe12fc70e2 to your computer and use it in GitHub Desktop.
How to reproduce the "Metadata not found" error for data history?
// Choose a victim for our bloody experiment.
MetadataObject = Metadata.Catalogs.Items;
ObjectsManager = Catalogs.Items;
// Enable data history for the catalog.
Settings = New DataHistorySettings;
Settings.Use = True;
DataHistory.SetSettings(MetadataObject, Settings);
// Create a new data history version.
Selection = ObjectsManager.Select();
Selection.Next();
CatalogObject = Selection.Ref.GetObject();
CatalogObject.Lock();
CatalogObject.Description = CatalogObject.Description + " (updated)";
CatalogObject.Write();
// Disable data history for the catalog and delete all stored versions. What could possibly go wrong?
DataHistory.SetSettings(MetadataObject, Undefined);
DataHistory.DeleteVersions(MetadataObject);
// Well, try to update data history and then... BOOM
DataHistory.UpdateHistory();
@vkostyanetsky
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment