Set default custom field value based on another field value
Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com

Set default custom field value based on another field value

You can configure custom fields to automatically display a default value based on the Event Label. This can be useful when the expected custom field value depends on the type of visit being collected.

This approach should be used only when the Event Label value exactly matches one of the configured values for the custom field. Otherwise, the field may not display the expected default value.

1. Set custom field values based on event label

Use the defaultValue property with a conditional expression to set different default values based on the visit's event label.

{ "name" : "visit.extensionDetail.attrsMap.cohort", "caption" : "Custom Cohort", "type" : "pvs", "attr" : "event_cohort", "optional" : true, "showWhen" : "visit.status != 'Missed Collection' && visit.status != 'Not Collected'", "defaultValue" : "field: visit.eventLabel == 'Baseline' ? 'Bipolar' : visit.eventLabel == 'Follow-up' ? 'Placebo' : null" }, For Event 'Baseline' defaulted value is Bipolar. See below screenshot For Event Follow-up, the default value is Placebo. See below screenshot

2. Set custom field value defaulted to event label value

When event label and visit custom field PV values are the same then you can set the custom field default value wrt to the visit.

Use case: When you collect the 'PMCT' visit the 'Art der Untersuchung' value should display default as 'PMCT'.

Add the below code in the JSON dictionary { "name" : "visit.extensionDetail.attrsMap.art_der_untersuchung", "caption" : "Art der Untersuchung", "type" : "radio", "optional" : true, "options" : [ "Klinische Angaben", "Sektion", "PMCT", "PM Ultraschall" ], "defaultValue": "field: visit.eventLabel" } Screenshot:

 

Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com