Skip to main content
Aug 31, 2020 4:09 PM UTC
Solved

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!

    RacconeAnswer
    Sep 1, 2020 10:11 AM UTC

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

     

     

    2 replies

    RacconeAuthorAnswer
    Sep 1, 2020 10:11 AM UTC

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

     

     

    Sep 1, 2020 10:24 AM UTC

    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