cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Using the DataTableThing.AddDataTableEntry in the Java Extension SDK

Raccone
10-Marble

Using the DataTableThing.AddDataTableEntry in the Java Extension SDK

Dear Developers,

 

I am trying to use the method in the subject, but I am unable to. Checking the documentation, this is the signature:

public void UpdateDataTableEntry(TagCollection tags,
                                                                           Location location,
                                                                           java.lang.String source,
                                                                           java.lang.String sourceType,
                                                                           InfoTable values)
                                                                    throws java.lang.Exception

And all the fields besides tags and values are optional. I am wondering what optional does mean in this case (null value?) as this is the only signature available. I have built the values like this, as an example:

 

InfoTable values = new InfoTable();
ValueCollection row = new ValueCollection();

row.SetIntegerValue("id", id);

values.addRow(row);

 

and I am not sure about what is the purpose of the tags in this case.

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Raccone
10-Marble
(To:Raccone)

I solved this one myself, I was passing the row in an incorrect way and it resulted empty:

DataShapeDefinition dsd = new DataShapeDefinition();
dsd.addFieldDefinition(new FieldDefinition("id", "NUMBER"));

InfoTable values = new InfoTable(dsd);
ValueCollection row = new ValueCollection();
		
row.SetNumberValue("id", id);
values.addRow(row.clone());

TagCollection tags = new TagCollection();
someTable.AddDataTableEntry(tags, null, null, null, values);

 

 

View solution in original post

2 REPLIES 2
Raccone
10-Marble
(To:Raccone)

I solved this one myself, I was passing the row in an incorrect way and it resulted empty:

DataShapeDefinition dsd = new DataShapeDefinition();
dsd.addFieldDefinition(new FieldDefinition("id", "NUMBER"));

InfoTable values = new InfoTable(dsd);
ValueCollection row = new ValueCollection();
		
row.SetNumberValue("id", id);
values.addRow(row.clone());

TagCollection tags = new TagCollection();
someTable.AddDataTableEntry(tags, null, null, null, values);

 

 

jman87
14-Alexandrite
(To:Raccone)

Hi Raccone

 

As my understanding, you can identify the optional parameter business meaning only if we pass the required parameter type (such as string type, infotable type). 

Based on help center introduction regarding Data Table Services, provide below demo for understanding the meaning of the parameters (even though below table is the output of another service):
2020-09-01_18-17-49.jpg

Below is my demo fragment for values:

var values = Things["VendingMachineInventoryTable"].CreateValues(); //or    var values=me.CreateValues();

values.productID = ProductID; //STRING
values.currentInvQty = Current; //NUMBER
values.vendPosition = Position; //NUMBER [Primary Key]
values.positionCapacity = Capacity; //NUMBER
values.productPrice = Price; //NUMBER

 

Best Wishes!

Teresa

Top Tags