Working …
This value you provided is not a number. Please try again.
This value you provided is not an integer. Please try again.
The value entered is not a valid Vanderbilt Medical Record Number (i.e. 4- to 9-digit number, excluding leading zeros). Please try again.
The value you provided must be within the suggested range
The value you provided is outside the suggested range
This value is admissible, but you may wish to double check it.
The value entered must be a time value in the following format HH:MM within the range 00:00-23:59 (e.g., 04:32 or 23:19).
This field must be a 5 or 9 digit U.S. ZIP Code (like 94043). Please re-enter it now.
This field must be a 10 digit U.S. phone number (like 415 555 1212). Please re-enter it now.
This field must be a valid email address (like joe@user.com). Please re-enter it now.
The value you provided could not be validated because it does not follow the expected format. Please try again.
Required format:
REDCap Logo
Plugins, Hooks, & External Modules
Developer methods for
Plugins, Hooks, & External Modules
Hook functions

REDCap Developer Tools:
Documentation for Plugins, Hooks, & External Modules

REDCap Version 14.9.1
REDCap::getSurveyLink
(REDCap >= 5.11.0)
REDCap::getSurveyLink — Obtains the survey link for a specific record on a specific survey instrument (and for a specific event, if a longitudinal project) - assumes the record already exists
Description
string REDCap::getSurveyLink ( string $record, string $instrument [, int $event_id = NULL [, int $repeat_instance = 1 [, int $project_id = NULL ]]] )
Obtains the survey link for a specific record on a specific survey instrument (and for a specific event, if a longitudinal project). This method assumes the record already exists.
Parameters
record
The name of the record/response to which the survey link belongs.
instrument
The name of the data collection instrument (i.e., the unique name, not the instrument label) to which this survey corresponds. This corresponds to the value of Column B in the Data Dictionary.
event_id
(longitudinal projects only) The event ID number that corresponds to a defined event in a longitudinal project. For classic projects, the event_id is not explicitly required, and thus it will be supplied automatically since there will only ever be one event_id for the project.
repeat_instance
(only for projects with repeating instruments/events) The repeat instance number of the repeating event (if longitudinal) or the repeating instrument (if classic or longitudinal).
project_id
The project ID (PID) number of the project. This parameter is optional if this method is called within the project context. Providing project_id allows this method to be called outside the target project context.
Return Values
Returns the survey link (i.e., full survey URL) for this record-instrument[-event], else it returns NULL if survey link was not found (i.e., if any parameters are incorrect).
Restrictions
If the project_id parameter is not provided explicitly, then this method can ONLY be used in the target project's project context (i.e. when "pid" parameter is in the query string of the plugin URL) or else a fatal error is produced.
Examples
Example #1:
This example illustrates how to obtain the survey link for a specific record for a specific survey instrument in a classic (non-longitudinal) project.
// We have our record name and instrument name
$record = '101';
$instrument = 'participant_info_survey';

// Get the survey link for this record-instrument
$survey_link = REDCap::getSurveyLink($record, $instrument);
Example #2:
This example demonstrates how to obtain the survey link for a specific record-survey-event longitudinal project.
// We have our record name, instrument name, and event_id
$record = '101';
$instrument = 'participant_info_survey';
$event_id = 339;

// Get the survey link for this record-instrument-event
$survey_link = REDCap::getSurveyLink($record, $instrument, $event_id);
REDCap 14.9.1 - © 2024 Vanderbilt University