I’ve made my first bit of progress but it still isn’t solved… I was able to put the following formula ${calc_prev_type} in a calculate question within group_graft (which is inside of the repeat called repeat_graft) and it properly displays the value from the previous repeat of the select_graft_type when it is referenced in a note question.
if(position(current()/../..) > 1, /data/repeat_graft[position() = position(current()/../..) - 1]/group_graft/select_graft_type, '')
It properly displays those values regardless of whether I have variable in the repeat_count of the repeat_graft, or repeat_count is blank and I create instances of the repeat as I go, so it looks like that isn’t the issue.
However, when I put that formula directly in the calculation column of the select_graft_type question I get an ODK validation error:
{"message":"The given XLSForm file was not valid. Please see the error details for more information.","code":400.15,"details":{"error":"ODK Validate Errors:\n>> XForm is invalid.\n: Cycle detected in form's relevant and calculation logic!\nThe following nodes are likely involved in the loop:\n${calc_prev_type}\n${select_graft_type}\n\nThe following files failed validation:\n${tmp9_aurdzx}\n\nResult: Invalid","warnings":null}}
When I put ${calc_prev_type} into the calculation column of select_graft_type question, I get an insanely long ODK Validation error that identifies tons of variables in my form.
Insanely Long ODK Validation Error
"message":"The given XLSForm file was not valid. Please see the error details for more information.","code":400.15,"details":{"error":"ODK Validate Errors:\n>> XForm is invalid.\n: Cycle detected in form's relevant and calculation logic!\nThe following nodes are likely involved in the loop:\n${calc_harvest_kgs_cashew_seeds}\n${select_graft_problem}\n${select_graft_yes_no_maybe}\n${photo_plant_id}\n${c_test4}\n${vol_est_wb_per_65}\n${animal_wild}\n${harvest_cashew_seeds_unit}\n${photo_bark}\n${select_weather_type}\n${calc_propagated_by_plant_id}\n${photo_new_branches}\n${group_water_use}\n${plant_id}\n${vol_est_wb_75}\n${audio_name_no_plant_id}\n${gps_no_plant_id}\n${select_rootstock_species}\n${audio_detailed4}\n${calc_common_name}\n${select_rootstock_unknown}\n${select_graft_person}\n${group_graft}\n${animal}\n${photo_animal_damage}\n${graft_qty_bowl_large}\n${photo_graft_bowl_large}\n${marking_graft}\n${group_rain}\n${calc_hole_volume}\n${budwood_qty_this_week}\n${calc_test1}\n${photo_detailed4}\n${variety_new}\n${name_common_eng}\n${name_scientific}\n${form_ver}\n${shoots_diameter_3}\n${debug_static_pulldata}\n${calc_imp_hole_vol}\n${calc_imp_hole_alt}\n${calc_imp_hole_precision}\n${calc_imp_hole_long}\n${calc_imp_hole_lat}\n${calc_imp_hole_loc}\n${group_alive}\n${photo_scion}\n${calc_harvest_kgs_cashew_apples}\n${obs_growth}\n${harvest_kgs_cashew_seeds}\n${photo_flowering}\n${select_flowering_amount}\n${calc_compost_volume_75}\n${group_harvest}\n${harvest_cashew_apples_unit}\n${select_harvest_cashew_detailed}\n${note_summary_harvest_cashew_apples}\n${plant_id_rootstock}\n${calc_coyah_bags}\n${plant_health}\n${calc_plant_health}\n${group_monthly}\n${plant_action_needed}\n${group_cashew_new}\n${calc_temp_id}\n${budwood_qty_this_month}\n${audio_name_no_plant_id}\n${gps_no_plant_id}\n${graft_qty_sac_small}\n${photo_graft_sac_small}\n${calc_total_seeds_germinated}\n${container_other_type}\n${group_fire}\n${calc_hole_far2}\n${photo_damage_other}\n${fertilizer_other_type}\n${photo_burned}\n${calc_variety_name}\n${group_propagation}\n${calc_old_cashew_ID_far}\n${group_survey_new}\n${group_container}\n${photo_germination_seed_source}\n${harvest_kgs_cashew_both}\n${calc_now}\n${harvest_kgs_cashew_apples}\n${group_compost_old}\n${group_compost_new}\n${photo_graft_10l_bucket}\n${graft_qty_10l_bucket}\n${group_hole_dimensions2}\n${note_hole_volume}\n${calc_scientific_name}\n${calc_harvest_cashew_apple_kg}\n${calc_test2}\n${calc_ID_from_URL}\n${group_transplanted}\n${calc_barcode1}\n${calc_compost_volume}\n${calc_hole_near}\n${current_time}\n${group_compost}\n${row_spaces}\n${select_container_type}\n${shoots_diameter_4}\n${hole_width}\n${hole_length}\n${damage}\n${air_layer_potential_count}\n${fruit_mature}\n${photo_fruiting}\n${audio_detailed3}\n${photo_monthly}\n${photo_shade}\n${sun_shade_rating}\n${height_pruned}\n${note_pruning_budwood}\n${photo_pruning}\n${year_prop}\n${photo_detailed2}\n${cutting_potential_count}\n${select_rooting_powder}\n${calc_hole_depth}\n${select_rootstock_same_species}\n${graft_qty_25l_bucket}\n${photo_graft_25l_bucket}\n${current_year_2}\n${select_prop_IID}\n${calc_prop_id_w_prefix}\n${year_prop}\n${select_rootstock_species}\n${calc_cashew_seeds_per_kg}\n${photo_top_working}\n${shoots_quantity}\n${note_measure_shoots}\n${photo_graft_known_rootstock}\n${vol_est_wb_85}\n${group_bourne}\n${calc_roostock_same_species}\n${current_year}\n${calc_old_cashew_ID_near}\n${calc_compost_volume_66}\n${group_nursery}\n${graft_qty_known_rootstock}\n${group_harvest_fruit}\n${calc_avg_g_fruit}\n${note_grafting}\n${group_grafting}\n${repeat_graft}\n${vol_est_wb_per_75}\n${calc_graft_id}\n${fertilizer_other_quantity}\n${calc_compost_volume_50}\n${calc_compost_volume_25}\n${seed_grams}\n${budwood_qty_immediately}\n${current_month}\n${nursery_location}\n${string_nursey_other}\n${plant_problem}\n${tree_growth}\n${group_harvest_cashew}\n${group_quarterly}\n${barcode1}\n${barcode1_rootstock}\n${calc_hole_far}\n${group_plant_action}\n${photo_diseased}\n${group_propagation_graft}\n${calc_hole_shape}\n${calc_compost_volume_bags}\n${select_multiple_rootstock_containers}\n${graft_qty_container_type_other}\n${photo_graft_container_type_other}\n${photo_lost_leaves}\n${calc_total_seeds_planted}\n${photo_rotten}\n${group_harvest_cashew_seeds_detailed}\n${photo_graft_union}\n${photo_budding}\n${current_year_month}\n${calc_common_name_fr}\n${gps_no_plant_id_rootstock}\n${calc_prop_id_w_prefix}\n${select_scion_readiness}\n${harvest_cashew_apples_detailed_count}\n${repeat_cashew_apple}\n${plant_trunk_diameter}\n${hole_diameter}\n${calc_select_container}\n${calc_preferred_propagation_plant_id}\n${select_plant_actions_needed}\n${calc_black_bags}\n${photo_graft_bowl_small}\n${graft_qty_bowl_small}\n${calc_avg_g_cashew_seed}\n${calc_cashew_date}\n${prev_graft_type}\n${calc_avg_seeds_fruit}\n${photo_graft_sac_long}\n${graft_qty_sac_long}\n${source}\n${graft_qty_20l_bucket}\n${photo_graft_20l_bucket}\n${calc_barcode1_length}\n${group_germination}\n${plant_gps}\n${audio_problem_other}\n${group_transplanted_yes}\n${audio_detailed5}\n${photo_detailed5}\n${graft_self_rating}\n${calc_ID_from_URL}\n${calc_id_type}\n${budwood_ready_count}\n${germination_end_count}\n${photo_germination_end}\n${note_calc_total_seeds_germinated}\n${calc_prev_type}\n${date_grafted}\n${select_transplant_year_cashew}\n${calc_avg_kgs_fruit}\n${select_plant_id_species}\n${audio_name_no_plant_id_rootstock}\n${calc_row}\n${calc_plant_id_rootstock}\n${group_rootstock_1}\n${calc_fertilizer_quantity}\n${photo_broken}\n${shoots_diameter_5}\n${calc_avg_seeds_kg}\n${budwood_qty_this_year}\n${group_grass_cutting}\n${select_nursery}\n${no_id_password}\n${group_comments}\n${group_plant}\n${calc_plant_health}\n${photo_plant_id}\n${audio_detailed2}\n${calc_scientific_name_rootstock}\n${select_germination_containers}\n${germination_start_count}\n${photo_germination_start}\n${date_seeds_planted}\n${note_calc_total_seeds_planted}\n${group_wind}\n${container_other_type}\n${calc_hole_diameter}\n${photo_detailed3}\n${vol_est_wb_65}\n${calc_hole_length}\n${calc_hole_width}\n${marking_text_graft}\n${note_graft}\n${location}\n${calc_plant_id}\n${calc1}\n${current_day}\n${group_cashew_new2}\n${calc_avg_g_cashew_apple}\n${calc_grafts_rootstock_total}\n${shoots_diameter_1}\n${photo_insect}\n${select_fertilizer_type}\n${select_fertilizer_quantity}\n${grass_cutting_man_days}\n${grass_cutting_GNF}\n${photo_damage_graft}\n${germination_percentage}\n${calc_problem_cause_default}\n${calc_water_meter_L}\n${gps_no_plant_id_rootstock}\n${audio_name_no_plant_id_rootstock}\n${shoots_diameter_2}\n${calc_default_graft_known_rootstock}\n${select_graft_type}\n${photo_graft_15l_bucket}\n${graft_qty_15l_bucket}\n${group_hole_dimensions}\n${plant_id}\n${photo_new_leaves}\n${photo_monthly}\n${vol_est_wb_per_85}\n${c_test3}\n\nThe following files failed validation:\n${tmp4fz1isff}\n\nResult: Invalid","warnings":null}}
When I put ${calc_prev_type} into the default column of select_graft_type, the form validates, the calculation displays properly in the note, but there is no answer selected as the default. Here is the full form with ${calc_prev_type} in the default column of select_graft_type.
Farm_Observations New Template (1).xlsx (383.0 KB)
The fact that the calculate field displays properly in a note within the group inside the repeat, tells me that the formula is working properly, but there might be a bug when evaluating default for a group within a repeat…? This definitely dampens my current prospects of a workflow for grafting where typically the values are almost always going to be the same as the first instance, but want the option for the user to be able to change these easily, but not have to choose them every single time if they are identical.