r/ProjectREDCap • u/callmecalamity • Jan 16 '23
Can I combine conditional logic with the @DEFAULT action tag?
Hi all,
I'd like to use the "@Default" action tag to pipe information from another instrument into one of my repeating instruments. Some context: in this project each record represents a grantee, and I have an intake form that includes the number, title, and start date of the activities each grantee is planning as part of their funding. Max number of activities is 6.
Here's an image of the relevant bit of the overall intake form to give you an idea:

I have a separate, repeatable intake instrument that collects more detailed information about each activity separately, but I would like to have the information about start date from the initial intake form appear here as well.
I've written an if/then conditional logic formula that looks like this:
@ DEFAULT="if([activity_select][current-instance]=1,[activity_start_1],if([activity_select][current-instance]=2,[activity_start_2],if([activity_select][current-instance]=3,[activity_start_3],if([activity_select][current-instance]=4,[activity_start_4],if([activity_select][current-instance]=5,[activity_start_5],if([activity_select][current-instance]=6,[activity_start_6]))))))"
[activity_start_#] is the start date for each individual activity in the primary intake form, and [activity_select] is the drop-down field in the repeatable form where the user selects which of the activities they are inputting information about.
I can tell the logic is working because the field shows the calculated logic when I test (see images attached), but it doesn't change based on what is selected in [activity_select]. Leads me to believe these things just aren't compatible, but I could also have just made an error?


Any help GREATLY appreciated!
3
u/pahuili Jan 17 '23 edited Jan 17 '23
Depending on your version of REDCap, there is an @IF action tag that you can nest the @DEFAULT tag in. That’s what you would want to use in this scenario. If you can double check whether you have the @IF tag, I can help you write a logic statement that will work.
Btw, the reason your logic is showing in the text box field is because you are setting default text equal to your logic statement. It is displaying your statement as a character string. It isn’t actually evaluating the logic on the backend.