You can subscribe to this forum after you log in or create your free account..
Posted: 2021-11-23 05:21 PM
Is it possible to get the corresponding template name or Id of an Instance through the Automation Interface? My goal is to be able to find out if a property is overridden in the template
My code snippet is
InstanceFullName = "ParentGroup.InstanceName"
Set obj = server.FindObject(InstanceFullName)
TemplateId = obj.TemplateId
InstanceId = obj.InstanceId
I see that TemplateId is always 0 but InstanceId gives me the Id of ParentGroup if ParentGroup is another Template Instance otherwise I get 0
Eventually I would like to execute the following method on a few property names
tobj.PropertyOverride(TemplateId, PropertyName) (tobj -> Item inside the template)
Posted: 2021-11-24 08:15 PM
I think you'll probably want the 'ParentTemplateId' property.
Which is described as "Reference to the template containing the object, if any."
So if the object has a ParentTemplateId that is not -1 then it is from a template, and you could reference the ID to obtain that template.
Posted: 2021-11-29 09:49 AM
I don't see a ParentTemplateId method for SCXV6Object. I think you might have referred to the Property ParentTemplateId. I get -1 for both for an independent object( not part of any template) or a template object. I think the reason could be because the object I am checking is inside a template instance. So when I try ParentInstanceId, I get the "Id" of the Parent Group Instance.
I think I can work with this idea:
Lets say obj is the object for which I have to check if a property is overridden
1. Get the Parent Instance Id : obj.Property("ParentInstanceId")
2. Find the corresponding Group Object:
3. Get the Template Id property from the Group Object ( we cant use this on obj because it will fail)
4. Find the Corresponding Template Object ( tObj )
5. Use the Find method under SCXV6Object to see if the Instance Name ( obj.Name ) exists in the template
6. If it exists then use the PropertyOverride method: tObj.PropertyOverride( tpObj.Id, propertyName). This would return either TRUE or FALSE
tpObj would be Nothing if obj.Name doesn't exist in the Template
Posted: 2021-11-29 01:41 PM
I don't see a ParentTemplateId method for SCXV6Object. I think you might have referred to the Property ParentTemplateId.
Huh? Wasn't my first sentence exactly this.. "I think you'll probably want the 'ParentTemplateId' property."
But yes, my mistake, the ParentTemplateId property applies to tell if a point is within a Template (and which Template), not whether it is within an Instance of a Template. So it is the 'ParentInstanceId' property you would want.
ParentInstanceId should return you the ID of the CTemplateInstance in which your object is located (if it is associated with an instance).