Skip to main content
1-Visitor
August 31, 2020
Solved

Using the DataTableThing.AddDataTableEntry in the Java Extension SDK

  • August 31, 2020
  • 2 replies
  • 1748 views

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!

    Best answer by 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);

     

     

    2 replies

    Raccone1-VisitorAuthorAnswer
    1-Visitor
    September 1, 2020

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

     

     

    15-Moonstone
    September 1, 2020

    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