-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alternative defaults not triggered in first survey instance #55
Comments
@JuliaSprenger Sorry for the delay, can you share your project xml? |
Sorry for the delay, here's the corresponding corresponding project xml (I changed the file extension to zip to be able to upload the file here) Two notes on this project file:
|
@mbentz-uf Any updates on this? Also if you know a workaround for this issue, this would already be a great help. |
@ChemiKyle Do you have any ideas for this? |
Hi @JuliaSprenger, Looks like there's a bit of odd behavior with a hardcoded string in I'd assume your actual survey is a bit more complicated? I think fixing this bug would benefit from a real example, since a string value set Bug:
Here is what appears when creating a new record (bottom left) and initiating a survey response (bottom right): Note that when using After clicking "Recommencer cette enquête" (restart this survey; creates a new instance in the same record) the value auto_populate_fields/ExternalModule.php Line 35 in be3ae04
This line does not behave as expected on instance 1 of a survey response. auto_populate_fields/ExternalModule.php Line 307 in be3ae04
|
Hi @ChemiKyle! |
It looked like some logic quirks make APF not activate at all on the first response of a survey. Unfortunately those logic quirks were in REDCap core so it would take more time than I have at the moment to find a workaround in the module. However, if you're looking for a more immediate solution, you could probably use REDCap JavaScript Injector to fill that particular field if it's blank. function fillIfBlank(field_name, value) {
let $target_field = $(`input[name='${field_name}']`);
// Don't overwrite field if a value is there
if ($target_field.val() != "") { return; }
$target_field.val(value);
// trigger field validation
$target_field.blur();
}
$(document).ready(function() {
fillIfBlank("my_field_name", "default value if field is blank")
}); In the 2nd to last line, you'd just change "my_field_name" to the target field's coded name (not its label) and "default value if field is blank" to ... the default value if the field is blank. |
@ChemiKyle Thanks for the explanations. If the origin of the bug is in RedCap itself, should I raise this issue also in another repository to be potentially addressed in a future RedCap release? Unfortunately, injecting JavaScript snippets for each project is not very feasible for me and out of the scope of my work, but thanks for the hint, I didn't know that module before. |
When creating a survey that can be repeated and contains a field with multiple alternative default values, these default values are not displayed when the survey is loaded the first time (filling of first instance).
A minimal example instrument to observe this is
When configuring this instrument as a repeatable survey, I would expect the
field1
to be prefilled for all instances of the survey. However, this is only the case for all but the first instance.The used versions are: Server info: REDCap 11.1.0 · PHP 7.3.27-1~deb10u1 (Linux/Unix OS) · MariaDB 10.3.27, Auto Populate Fields - v2.6.0
The text was updated successfully, but these errors were encountered: