Create UDT Instance with specified UDT Definition in ManagedTagProvider

Hello, I am struggling to determine how to create a UDT Instance with a specified UDT parent data type in version 8.1.48 of the java SDK.

I am able to create a UDT definition for a ManagedTagProvider as follows:

// create ManagedTagProvider
ProviderConfiguration configuration = new ProviderConfiguration(name);
        configuration.setAllowTagCustomization(true);
        configuration.setPersistTags(false);
        configuration.setPersistValues(false);
        configuration.setAllowTagDeletion(true);
        configuration.setAttribute(TagProviderMeta.FLAG_PROVIDES_COMPLEX_TYPES, true);

// assume context (of type GatewayContext) is defined 
ManagedTagProvider provider = context.getTagManager.getOrCreateManagedProvider("My Provider", configuration); 

// create UDT Definition
TagConfiguration myDefinition = new TagConfigurationBuilder().name("MyDefinition").property(WellKnownTagProps.TagType, TagObjectType.UdtType).build();
provider.configureTag("MyDefinition", myDefinition)

It is unclear how to define a UDT Instance with the Parent Data Type set, and I have been unable to find this documented anywhere. I have tried the following:

  • set WellKnownUDTParameters.PathToParentFolder to the UDT definition path
  • set the UDT instance TagConfiguration as a child of the UDT definition
  • set UDT Instance DataType tag property to the UDT defintion

If anyone knows of a way to do this I would appreciate it! Thanks!

UDT definitions have to be placed under the _types_ folder in the provider. Try that.

It seems both: provider.configureTag("_types_/Blower", modelConfig) and provider.configureTag("Blower", modelConfig) work to create UDT Definitions.

I am able to successfully create UDT Definitions:

Where I having issues is specifying the definition for a UDT Instance I create for the Tag Provider:

TagConfiguration instanceConfig = new TagConfigurationBuilder().member("_types_/Blower").name("Blower1").property(WellKnownTagProps.TagType, TagObjectType.UdtInstance).build();
provider.configureTag("Blower1", instanceConfig);

But the resulting Tag has issues:


That doesn't look right. I would expect you to need to set WellKnownTagProps.TypeId to "Blower".

2 Likes

That works, thank you!