Products | Versions |
---|---|
Spotfire Developer | All Versions |
Document.ActivePageReference.Id == 4fb8eaf3-b5b4-4525-8028-b7a699c6e7d0. The GUID is the five sectioned hashstring.
When a linked analysis is opened, the document is cloned since it cannot be shared. When a Visual is cloned, a new GUID is generated (see GetObjectData method in Visual). If the document has linked data, the entire document must be cloned to create a local version of the data table. This will also rebuild the GUID identifiers, since we now have a new node tree. This is a common occurrence when an analysis is opened on the Web Player. In general, we can never assume that the GUIDs will be the same when an analysis is opened on different clients (Desktop vs Web Player).
GUIDs should be used very sparsely. If we temporarily have multiple objects and need to identify them by something other than TypeId and Title, we can use the GUID. If there are multiple objects with the same name, it may be useful to compare them using the GUID.
if (myObject.Id == guid) {do something}
Usually it is better to use the object reference instead. GUIDs can only be used to identify objects, whereas object references are also called upon the object itself. Using the Title is the preferred way to find and compare objects of the same type. Object TypeIdentifiers are used to identify the sub-type of each object (ListBoxFilter, BarChart, etc.). If you are writing extension code, see 'UndoableCrossReferenceProperty' below.
Store object reference and use that:
Document doc = AnalysisApplication.Document; doc.ActivePageReference = doc.Pages[2];
if (myObject.Title == otherObject.Title) {do something}
if (visual.TypeId == VisualTypeIdentifiers.BarChart) { visual.TypeId = VisualTypeIdentifiers.LineChart; }
The UndoableCrossReferenceProperty is used in the Spotfire C# extension code and fulfills the same purpose as the GUID. It is a static property that is permanently linked to a specific object in the node tree. From there on it can be used as a permanent reference to that object. The UndoableCrossReferenceProperty, unlike the GUID, is guaranteed to always work even if the surrounding Document changes. Always use the UndoableCrossReferenceProperty when working with extension code when you need a permanent reference to a specific object.