question on use of validation scripts

LabKey Support Forum
question on use of validation scripts Ben Bimber  2011-02-09 10:34
Status: Closed
 
The EHR has a list called projects. It has one row per project. Periodically the university sends us a TSV list of all projects. Some of these rows may be different from existing rows, but most are not. I would like to create a mechanism such that a user can cut/paste the entire list from UW, hit upload, then let some code run that figures out whether each row needs to be updated then only makes changes if needed. Can validation scripts be used to contain that logic?

The basic idea is:

- accept TSV input in text area
- some code needs to perform some simple transform/validation on the fields
- per each transformed row, compare to existing table based on project field (the PK). if changes exist, update, if not, do nothing. a validation script could be made to abort with an error, but I dont know if it can be made to simply skip a row without failing the entire batch.

The alternative is to wipe the entire table and replace; however, I'd prefer to retain the audit history on these records if possible.

The whole process could run client-side without a huge amount of work, but there's a lot of awkward back and forth between server and client.
 
 
jeckels responded:  2011-02-09 12:47
Hi Ben,

Validation scripts don't currently have a way to skip a particular row without rejecting the whole set of rows. Doing an update that doesn't actually change any values shouldn't be a problem, though it would insert audit records for datasets and lists.

There's also the problem that some of these rows would be updates and some would be inserts. In the future, we hope to support a merge-style option as well, which would address this case, but for now the client would need to know which to do, and at that point it's probably just as easy to figure out if anything's changed for that row.

Thanks,
Josh
 
Ben Bimber responded:  2011-02-09 12:51
hi josh,

the point of doing a selective update would be to avoid overloading the audit table such that the information in it becomes more intelligible. doing a purely client-side approach is not that different from what we're doing with assays at the moment, so i think we'll do that.

-ben
 
michael_stover responded:  2011-02-10 06:54
What we have done for datasets of clinical studies is create whole web pages with javascript that takes data entered into a form and populates the dataset tables. I would think you could do something similar, and use the javascript client API to do all the processing of their list of projects and update/add entries to the list as you like.