creating both sides of a FK using LABKEY.Query.saveRows() | Ben Bimber | 2017-08-01 17:52 |
Status: Closed | ||
Hi Will, In situations where we've done this, you could consider: 1) can you use a string PK, instead of the rowID? There's a LABKEY.Utils method to generate a GUID, for example. this way you could establish the key upfront, and insert both rows in a transaction as you're doing w/ saveRows(). 2) You could add something in the server-side JS trigger scripts to do one of these two inserts. I'm not sure this is always the best pattern for what you describe (making a dedicated java action is probably cleaner), but it can be done. In other words, if you submit a wide row to the child table, if no matching value exists in the FK's source table, you do that insert into that table from code in the trigger script. -Ben |
||