Functions Available in the PTC Common Domain
The following functions are available in the PTC Common domain:
GetEnumTypeConstraint()
The function GetEnumTypeConstraint() is used to query the valid values for a property, which are represented as EnumType. These values are used for implementing validations on client side.
GetCSRFToken()
The function GetCSRFToken() is used to get the value of the nonce token that is used while creating, updating, or deleting entities in the system.
GetJWTFormRendererUrl()
The unbound function GetJWTFormRendererUrl() returns the URL to the e-signature page for tasks that require re-authentication.
For more information on requiring electronic signatures on workflow activities in Windchill, refer to the
Windchill Help Center.
GetAllStates()
The function GetAllStates() returns a list of life cycle states, which are available and can be selected in Windchill. The life cycle states that cannot be selected in Windchill are not returned. The life cycle states are retrieved from the StateRb.rbinfo file.
GetAllStates() is an unbound function, which is available in all the domains which import the PTC Common domain.
If the URL used to execute the function is not formed correctly, the function throws the URL malformed exception.
GetWindchillMetaInfo()
The GetWindchillMetaInfo() function returns the localized display names of service metadata for OData entities, structural, navigation and complex type properties that are available in the domain from which the function is called. The function is available to all domains that import the PTC Common domain.
There are a few variations of this function. They return a single complex type PTC.EntityMetaInfo, or an array of PTC.EntityMetaInfo. The function returns structural, navigation, and complex type properties.
A boolean property named IsEntityTypeComplex in the EntityMetaInfo is set to a value of true for complex type result items.
Note the following points when using the GetWindchillMetaInfo() functions:
• For entity types that are backed by a Windchill type, the function returns the display and internal names of the entity.
• For entity types that are not backed by a Windchill type, the function returns the internal names of the entity as null and the display names of the entity as defined in the rbInfoForDisplayName property, only when those are defined in the entity json configuration using the rbInfoForDisplayName property.
• For properties that are available on the OData entity, but are not available in Windchill, the function returns the value of display name as defined in the rbInfoForDisplayName property, only when it is defined in the entity json configuration using the rbInfoForDisplayName property.
• The function now returns the following information defined in the Type Manager for the format, Currency, and Percent property:
◦ The “Date and Time” attributes are for the Format property (DateFormat, String). The Format is locale-dependent and based on the Accept-Language HTTP header. For attributes that are not “Date and Time”, DateFormat is null
◦ The “Real Numbers”, “Real Number with units”, and “Integer” attributes are for the Currency property (boolean flags for Currency and Percent). For attributes that are not “Real Numbers”, “Real Number with units” and “Integer”, Currency and Percent are null.
|
Here, Currency is not a Quantity of Measure. It is a Type Manager configuration option, which is not locale dependent To manage currencies, it is recommended to use Real Number with the Units attributes, as described in the About Windchill Units topic.
|
• Depending on the language that you set in the request header, the function returns internal names and localized display names for Windchill types and properties.
For example, if you call the function from the PTC Principal Management domain, the response is as follows:
URI
GET /Windchill/servlet/odata/PrincipalMgmt/GetWindchillMetaInfo() HTTP/1.1
Request Header:
Accept-Language: en-US
The response is:
{
"@odata.context": "https://windchill.ptc.com/Windchill/servlet/odata/v3/PTC/$metadata#Collection(PTC.EntityMetaInfo)",
"value": [
...
{
"EntityType": "PTC.PrincipalMgmt.Group",
"BaseType": "PTC.PrincipalMgmt.Principal",
"HasWindchillType": true,
"DisplayName": "Group",
"InternalName": "wt.org.WTGroup",
"PropertyInfo": [
{
"PropertyName": "Description",
"DisplayName": "Description",
"InternalName": "description"
},
{
"PropertyName": "DomainName",
"DisplayName": "Name",
"InternalName": "administrativeDomainName"
}
],
"NavigationPropertyInfo": [
{
"PropertyName": "Users",
"DisplayName": "Members"
}
]
}
...
]
}
GetWindchillMetaInfo is overloaded by parameters as follows:
• To get the metadata display names for all the entities in the domain from which the function is called, specify the following URL:
GET <Domain_Name>/GetWindchillMetaInfo()
For example to get display names for the PTC Product Management domain entities, use the following URL:
GET ProdMgmt/GetWindchillMetaInfo()
• To get the metadata display names for a specific entity in the domain from which the function is called, specify the following URL:
GET <Domain_Name>/GetWindchillMetaInfo(EntityName='<name_of_the_entity>')
For example, to get display names for the Part entity, use the following URL:
GET ProdMgmt/GetWindchillMetaInfo(EntityName='PTC.ProdMgmt.Part')
The function also returns the global names and data types including the complex data types such as PTC.EnumType, PTC.QuantityOfMeasureType, PTC.Hyperlink, and so on for the properties in the Part entity. For example, when you call the function,
GET /Windchill/servlet/odata/ProdMgmt/GetWindchillMetaInfo(EntityName='PTC.ProdMgmt.Part')
the response is as follows:
{
"@odata.context": "https://windchill.ptc.com/Windchill/servlet/odata/v3/PTC/$metadata#PTC.EntityMetaInfo",
"@PTC.AppliedContainerContext.LocalTimeZone": "America/Chicago",
"EntityType": "PTC.ProdMgmt.Part",
"IsEntityTypeComplex": false,
"BaseType": "PTC.WindchillEntity",
"HaswindchillType": true,
"IsInstantiable": true,
"DisplayName": "Part",
"InternalName": "wt.part.WTPart",
"Propertylnfo": [
{
"PropertyName": "AlternateNumber",
"DisplayName": "Alternate Number",
"InternalName": "variation2",
"IsRichText": null,
"GlobalName": "IBA|reusableString"
},
{
"PropertyName": "LocalHyperlink",
"DisplayName": "Local Hyperlink",
"InternalName": "localHyperlink",
"IsRichText": null,
"DataType": "PTC.Hyperlink"
}
]
}
• Specify the URL GET <Domain_Name>/GetWindchillMetaInfo(IncludeAncestorProperty=true) to get the following:
◦ All the entities in a domain
◦ The properties of each entity inherited from the corresponding parent entity from the domain in which the function is called
◦ The metadata display names
For example, use the URL below to get all the entities and the inherited properties of each entity from its parent entity along with the metadata display names, for the PTC Product Management domain.
GET ProdMgmt/GetWindchillMetaInfo(IncludeAncestorProperty=true)
The response shows the structural and navigation properties of all the entities in the Product Management domain and the properties of each entity that are inherited from the parent entity along with the metadata display names.
• To get the metadata display names for an entity and its inherited properties from the parent entity, specify the following URL:
GET <Domain_Name>/GetWindchillMetaInfo(EntityName='<name_of_the_entity>',IncludeAncestorProperty=true)
For example, to get display names for the ElectricalPart entity and its inherited properties, use the following URL:
GET ProdMgmt/GetWindchillMetaInfo(EntityName='PTC.ProdMgmt.ElectricalPart',IncludeAncestorProperty=true)
The response shows the structural and navigation properties for the entity PTC.ProdMgmt.ElectricalPart as well as properties that are inherited from the parent entity PTC.ProdMgmt.Part.
If the value of IncludeAncestorProperty is set to false, GetWindchillMetaInfo does not return structural and navigation properties inherited from the parent entity PTC.ProdMgmt.Part.
Request URL is as follows:
GET /Windchill/servlet/odata/ProdMgmt/GetWindchillMetaInfo(EntityName='PTC.ProdMgmt.ElectricalPart',IncludeAncestorProperty=false)
• To get the metadata display names for a specified entity and its child entities, you must set the value of the property IncludeDescendants to true.
For example, to get the display names of a Supplier Part and its child properties, you can use the following URL:
GET /Windchill/servlet/odata/ProdMgmt/GetWindchillMetaInfo(EntityName='PTC.ProdMgmt.SupplierPart',IncludeDescendants=true) will return the parent supplier part as well as its child properties. Setting the value of IncludeDescendants to false will return only the parent entity.
• The PropertyType field is used to flag persistent attributes like model-based attributes (MBA) and instance-based attributes (IBA), as well as non-persistent attributes (NPA) and server-calculated attributes (SCA). For example, you can use the following URI:
GET /<WindchillURL>/servlet/odata/ProdMgmt/GetWindchillMetaInfo(EntityName='PTC.ProdMgmt.Part',IncludeDescendants=true), the response is as follows:
{
"EntityType": "PTC.ProdMgmt.Part",
"IsEntityTypeComplex": false,
"BaseType": "PTC.WindchillEntity",
"HasWindchillType": true,
"IsInstantiable": true,
"DisplayName": "Part",
"InternalName": "wt.part.WTPart",
"PropertyInfo": [
{
"PropertyName": "Identity",
"DisplayName": "Identity",
"InternalName": "displayIdentity",
"IsRichText": false,
"DataType": "Edm.String",
"ReadOnly": true,
"Common": false,
"Required": false,
"PropertyType": "ServerCalculated",
"GlobalName": null,
"Mapping": null,
"Formula": null
},
{
"PropertyName": "Number",
"DisplayName": "Number",
"InternalName": "number",
"IsRichText": false,
"DataType": "Edm.String",
"ReadOnly": false,
"Common": true,
"Required": false,
"PropertyType": "ModelBased",
"GlobalName": null,
"Mapping": null,
"Formula": null
},
{
"PropertyName": "OrganizationReference",
"DisplayName": "Organization Name",
"InternalName": "organizationReference",
"IsRichText": false,
"DataType": "Edm.String",
"ReadOnly": true,
"Common": false,
"Required": false,
"PropertyType": "NonPersisted",
"GlobalName": null,
"Mapping": "MBA|masterReference^WCTYPE|wt.part.WTPartMaster~MBA|organizationReference^WCTYPE|wt.org.WTOrganization",
"Formula": null
}
]
}
The value of the Mapping and Formula fields are non-empty for the Alias attributes and Calculated attributes, respectively.
GetWindchillVersion()
The
GetWindchillVersion() function returns information similar to the
windchill version command in the Windchill shell. For more information on the Windchill shell, see
About the windchill Command in the
Windchill Help Center. The function returns a list of installed modules along with the currently installed version of Windchill. Each installed module is represented as a Complex Type. For example:
[{
"AssemblyId":"mpml",
"AssemblyVersion":"13.0.0.0",
"AssemblyName":"windchill 13.0.0.0 mpmlink"
},
{
"AssemblyId":"odata",
"AssemblyVersion":"2.6.0.0",
"AssemblyName":"windchill 2.6 REST Services"
}]