Invite a Co-worker
Send a co-worker an invite to the Exchange portal.Just enter their email address and we’ll connect them to register. After joining, they will belong to the same company.
Send Invite Cancel
79398members
344143posts

Getting Template Name or id from an Instance

tkswathik
Lieutenant JG
Lieutenant JG
0 Likes
4
271

Getting Template Name or id from an Instance

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)

4 Replies 4
BevanWeiss
Spock
Spock

Re: Getting Template Name or id from an Instance

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.


Lead Control Systems Engineer for Alliance Automation (VIC).
All opinions are my own and do not represent the opinions or policies of my employer, or of my cat..
tkswathik
Lieutenant JG
Lieutenant JG
0 Likes
2
231

Re: Getting Template Name or id from an Instance

@BevanWeiss 

 

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

 

Thanks!!

BevanWeiss
Spock
Spock
0 Likes
1
226

Re: Getting Template Name or id from an Instance


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).

 


Lead Control Systems Engineer for Alliance Automation (VIC).
All opinions are my own and do not represent the opinions or policies of my employer, or of my cat..
tkswathik
Lieutenant JG
Lieutenant JG
0 Likes
0
223

Re: Getting Template Name or id from an Instance

Ah !! I overlooked it, my bad.

 

Thanks for your suggestion