Wrong column selected by Rlabkey when retrieving visits

LabKey Support Forum (Inactive)
Wrong column selected by Rlabkey when retrieving visits cnathe  2019-10-23 06:15
Status: Active
 

Edward,
I would advise against making direct updates to the back-end postgresql LabKey tables. As you mentioned there are several tables that reference the visit RowId that may be affected by a change to this table.

I was able to reproduce the behavior you are seeing locally using my Demo visit based study. As you are seeing, we return the visit RowIds by default for these selectRows query response. There is a parameter that you can pass to the labkey.selectRows call to help: includeDisplayValues=TRUE. This will add in a column for the visit label. Here is an example from my Demo Study:

labkey.data <- labkey.selectRows(
  baseUrl="http://localhost:8080/labkey", 
  folderPath="/Demo Study/Visit Study", 
  schemaName="study", 
  queryName="TestDataSet1", 
  colNameOpt="rname",
  includeDisplayValues=TRUE
)

  participantid participantvisit_visit field1 field2        review_state participantvisit_visit_label
1           123                   9749  test1      1 Reviewed-Rejected 2                           V1
2           123                   9750  test2      2 Reviewed-Rejected 2                           V2