Skip to main content
1-Visitor
September 17, 2016
Solved

How to get value of the field defined in Configuration Table while building an extension.

  • September 17, 2016
  • 15 replies
  • 8707 views

I can see option only for getDefaultValue() not getValue(). I followed as:

     getConfigurationTable("TableName").getField("fieldName").getDefaultValue().

The option for getValue() was not there, hence changes in configuration is not reflectiong after importing this extension in Thingworx Platform.

Best answer by nagarwal

Hi Vladi,

The below command worked for me -

     getStringConfigurationSetting("TableName", "PropertyName");

Regards,

Nitin

15 replies

19-Tanzanite
September 17, 2016

Hi Nitin,

Could you try getConfigurationData().getValue("TableName", "PropName") ?

Best regards,

Vladi

nagarwal1-VisitorAuthorAnswer
1-Visitor
September 19, 2016

Hi Vladi,

The below command worked for me -

     getStringConfigurationSetting("TableName", "PropertyName");

Regards,

Nitin

5-Regular Member
September 20, 2016

Hello,

If this is the correct answer, then could you please mark it as correct to help other developers find the answer to this in the future?

Thanks!

Tori

1-Visitor
October 13, 2016

Can you please provide code example?

String myProp = getStringConfigurationSetting("TableName", "PropertyName");

Is it just like this?

1-Visitor
October 13, 2016

Actually found answer in apendix A of thingworx_extension_development_user_guide.pdf.

@ThingworxConfigurationTableDefinitions(tables = {

@ThingworxConfigurationTableDefinition(name="ConfigTableExample1", description="Example 1 config table", isMultiRow=false, dataShape = @ThingworxDataShapeDefinition( fields = { @ThingworxFieldDefinition(name="field1",description="",baseType="STRING"), @ThingworxFieldDefinition(name="field2",description="",baseType="NUMBER"), @ThingworxFieldDefinition(name="field3",description="",baseType="BOOLEAN"), @ThingworxFieldDefinition(name="field4",description="",baseType="USERNAME")})),

@ThingworxConfigurationTableDefinition(name="ConfigTableExample2", description="Example 2 config table", isMultiRow=true, dataShape = @ThingworxDataShapeDefinition( fields = { @ThingworxFieldDefinition(name="columnA",description="",baseType="STRING"), @ThingworxFieldDefinition(name="columnB",description="",baseType="NUMBER"), @ThingworxFieldDefinition(name="columnC",description="",baseType="BOOLEAN"), @ThingworxFieldDefinition(name="columnD",description="",baseType="USERNAME") })) })

String field1Value = (String)getConfigurationSetting("ConfigTableExample1", "field1");

Double field2Value = (Double)getConfigurationSetting("ConfigTableExample1", "field2");

Boolean field3Value = (Boolean)getConfigurationSetting("ConfigTableExample1", "field3");

String field4Value = (String)getConfigurationSetting("ConfigTableExample1", "field4");

1-Visitor
June 8, 2017

It there any way to handle configuration change? For example regenerate internal values base on that config?

Maybe some event?

19-Tanzanite
June 9, 2017

Hi Jan,

There's no such an event regarding the configuration. Considering the typical usage, you always read the configuration parameters when you start the Thing.

If you need such a functionality you can store in internal properties (maybe an infotable holding all previous parameters) the old values then compare the new values to the old ones?

1-Visitor
June 9, 2017

I wanted to put internal logic to custom class:

MyCustomLogic cl = new MyCustomLocic(config1, config2);

Then in services:

     cl.method1();

I dont want to do:

     cl.setConfig(config1, config2);

on every service call...

Any solution to this?