Skip to content

Commit c4ebfb1

Browse files
committed
REDCap: describe how to retrieve event_id
1 parent d469411 commit c4ebfb1

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

REDCap.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
1+
- [Enable DETs for a project](#enable-dets-for-a-project)
2+
- [Find event ID for an event name](#find-event-id-for-an-event-name)
3+
14
## Enable DETs for a project
25

36
Within the REDCap project, go to Project Setup.
47
Find and click the Additional Customizations button.
58
Scroll to the bottom of the modal, and find the Data Entry Trigger section.
9+
10+
11+
## Find event ID for an event name
12+
13+
There is no official REDCap API for retrieving an event ID, but this event ID is required for generating deep links to specific instance of forms within REDCap.
14+
15+
To find the event ID, you can look at the `event_id` param in the URL of a form from your target arm and event.
16+
If there are no forms for the arm or event you're targeting, then with a little hacking, you can retrieve the event ID in the following way:
17+
1. From the home page of your target REDCap project, under **Project Home and Design**, click on **Project Setup**.
18+
2. Then, under **Define your events and designate instruments for them**, click `Define my events`.
19+
3. In your browser console, run the following JavaScript snippet:
20+
```js
21+
edit_links = document.querySelectorAll("a[onclick^=beginEdit]")
22+
parse_onclick = a =>
23+
a.getAttribute("onclick")
24+
.match(/beginEdit\("(?<arm>\d+)","(?<event_id>\d+)"\)/)
25+
.groups;
26+
console.table(
27+
Array.from(edit_links).map(a => ({
28+
name: a.parentElement.parentElement.querySelector(".evt_name").textContent,
29+
...parse_onclick(a)
30+
}))
31+
)
32+
```
33+
The resulting table detials the `event_id` for each event defined in the current tab's arm.
34+
Click through the other tabs to see `event_ids` for other project arms.

0 commit comments

Comments
 (0)