update one cell in a row (labkey java api)

LabKey Support Forum (Inactive)
update one cell in a row (labkey java api) liuy30  2017-05-11 13:57
Status: Closed
 
Hi,

I have a row in labkey which contains 10 cells:

key, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

for example, if i just want to update the value of cell 10, instead of putting everything into row = new HashMap<String,Object>();

is there a way to just provide the cell that needs to be updated using the UpdateRowsCommand();

Thank you very much.
 
 
Jon (LabKey DevOps) responded:  2017-05-11 14:47
Hello,

Using the UpdateRowsCommand, you need to indicate what row you want to update in addition to the specific field for that row.

If you look at the API docs here:

https://www.labkey.org/download/clientapi_docs/java-api/org/labkey/remoteapi/query/UpdateRowsCommand.html

https://www.labkey.org/download/clientapi_docs/java-api/org/labkey/remoteapi/query/SaveRowsCommand.html

You'll see the example:

  //Update Rows Command
  UpdateRowsCommand cmdUpd = new UpdateRowsCommand("lists", "People");
  row = new HashMap<String,Object>();
  row.put("Key", newKey);
  row.put("LastName", "Test UPDATED");
  cmdUpd.addRow(row);
  resp = cmdUpd.execute(cn, "PROJECT_NAME");

This allows the specific row to be updated and just that specific field for that one row.

Regards,

Jon