Creating ParticipantGroups using the JS API

LabKey Support Forum (Inactive)
Creating ParticipantGroups using the JS API rsautera  2015-05-18 16:07
Status: Closed
 
Hi,
I am trying to create participant groups programmatically. The use case is to automatically create participants groups for demographics after importing data (via an ETL) into a new study.

I was looking at the JavaScript API but it looks like there is a single function to update existing groups. Am I reading this correctly and all groups have to be created through the UI?

Even with the update, how can I get a list of the rowId of existing participant groups? I looked for them in the study schema (the subject table view can be customized to show participant groups) but I could not display the Id. I tried a few random Ids just to test the API but could not get a natch: "Could not find participant group with rowId 1"

Here is the doc I used:
https://www.labkey.org/download/clientapi_docs/javascript-api/symbols/LABKEY.ParticipantGroup.html#constructor
and
https://www.labkey.org/download/clientapi_docs/javascript-api/symbols/src/api_webapp_clientapi_core_ParticipantGroup.js.html
 
 
Jon (LabKey DevOps) responded:  2015-05-19 17:01
Hello,

Although you can get the RowIds by viewing the table, then customizing the view to Show Hidden Fields, then adding the RowId to your view, the system appears to prevent someone from doing an insert into the ParticipantCategory table and the ParticipantGroup table. So doing an insertRows or saveRows Javascript API call wouldn't work in this case.

The entire page that controls adding and managing participant groups is done by ParticipantGroup.js file that is under the Study server module, but I'm not seeing anything within it that could allow a Javascript API to insert in new groups (which it would have to first start by inserting into the ParticipantCategory table first, then use the RowId number from the ParticipantCategory table and use it in the ParticipantGroup table.

I'll confirm with our developers if there is a way to do this without having to use the UI to be certain.

Regards,

Jon
 
Jon (LabKey DevOps) responded:  2015-05-20 15:00
Hello,

So there isn't a supported way to create new Participant Groups via the Javascript API, but there is a way to do this. I'll send you the information directly, but please keep in mind that we don't guarantee it working consistently since we can change how the platform works when it comes to this. Essentially, the Participant Group is handled by the ParticipantGroupController within the Study module and the CreateParticipantCategory action handles adding the category along with the group.

Regards,

Jon