Dynamic Drop down not working in custom view

Hello,

I have searched but been unable to find a similar question in the forum. I’ve set up dynamic drop downs which work exactly as I expect them to when I add them to the edit view. I’ve included some screen shots from the regular edit screen where the drop downs work as expected. Part of Day depends on Unit Name and Unit Tasks depends on part of day.

However, I have a custom edit view which I would like to use these drop downs in, yet here they do not work correctly. No matter what choice I make in the parent drop down, the child drop down does not update. No matter what my choice for Unit Name the Part of Day choices do not update. Also, regardless of my Part of day Choice Unit Tasks do not update. I’ve included screen shots of this as well.

I would appreciate any help in where I should begin looking to solve this.

Thank you

Hi,
How you created this custom view, by custom coding??
Can you please share view code?
Thanks

The code is rather long as its used with multiple modules and unfortunately, I’m not the one who originally wrote it. I believe I have located the related code.

                if ($module == 'er_Unit_Task') {
                    global $app_list_strings;                    
                    $tasks_ops_2018_morning__c = $app_list_strings['tasks_ops_2018_morning__c_list'];
                    $tasks_ops_2018_afternoon__c = $app_list_strings['tasks_ops_2018_afternoon__list'];
                    
                    $morning_options_html = '';
                    foreach ($tasks_ops_2018_morning__c as $mkey => $mvalue) {
                        $morning_options_html  .= '<option value=\"' . $mkey . '\">'.$mvalue.'</option>';
                    }

                    $afternoon_options_html = '';
                    foreach ($tasks_ops_2018_afternoon__c as $akey => $avalue) {                         
                        $afternoon_options_html  .= '<option value=\"' . $akey . '\">'.$avalue.'</option>';
                    }
                    $tasks_morning__c = 'tasks_ops_2018_morning__c';
                    $tasks_afternoon__c = 'tasks_ops_2018_afternoon__c';

                    $toDisableUnitTaskFields = array('tasks_kitchen_prep_serve__c', 'tasks_kitchen_cleaning__c', 'tasks_ops_2018_morning__c', 'tasks_ops_2018_afternoon__c');
                    if ($def['name'] == 'work_order_day_period__c') {
                        foreach ($toDisableUnitTaskFields as $k_value) {
                            if (isset($thisViewsFieldsMetadata[$k_value])) {
                                $script_for_checkbox .= '$("#' . $k_value . '" + row_num ).prop("disabled","true");';
                            }
                        }
                    if ($view == 'multiple_unit_tasks') {
                        $script_for_checkbox .= '$("#' . $name . '" + row_num).change(toggleKitchenOptions);';
                    } else { 
                        $script_for_checkbox .= '$("#' . $tasks_morning__c . '" + row_num ).append("' . $morning_options_html . '");';
                        $script_for_checkbox .= '$("#' . $tasks_afternoon__c . '" + row_num ).append("' . $afternoon_options_html . '");';
                        $script_for_checkbox .= '$("#' . $name . '" + row_num).change(function(){
                            var value = $(this).val();                            
                            if(value == "Morning") {
                                $("#' . $tasks_afternoon__c . '" + row_num ).attr("disabled","true");
                                $("#' . $tasks_afternoon__c . '" + row_num ).addClass( "disabledRow" );
                                $("#' . $tasks_morning__c . '" + row_num ).removeClass( "disabledRow" );
                                $("#' . $tasks_afternoon__c . '" + row_num ).val("");
                                $("#' . $tasks_morning__c . '" + row_num ).removeAttr("disabled");
                                $("#' . $tasks_morning__c . '" + row_num ).append("' . $morning_options_html . '");
                            } else if (value == "Afternoon"){
                                $("#' . $tasks_afternoon__c . '" + row_num ).removeAttr("disabled");
                                $("#' . $tasks_morning__c . '" + row_num ).attr("disabled","true");
                                $("#' . $tasks_morning__c . '" + row_num ).val("");                                
                                $("#' . $tasks_afternoon__c . '" + row_num ).append("' . $afternoon_options_html . '");
                                $("#' . $tasks_morning__c . '" + row_num ).addClass( "disabledRow" );
                                $("#' . $tasks_afternoon__c . '" + row_num ).removeClass( "disabledRow" );
                            } else {
                                $("#' . $tasks_morning__c . '" + row_num ).val("");
                                $("#' . $tasks_afternoon__c . '" + row_num ).val("");
                                $("#' . $tasks_morning__c . '" + row_num ).addClass( "disabledRow" );
                                $("#' . $tasks_afternoon__c . '" + row_num ).addClass( "disabledRow" );
                                $("#' . $tasks_morning__c . '" + row_num ).attr("disabled","true");
                                $("#' . $tasks_afternoon__c . '" + row_num ).attr("disabled","true");
                            }
                        });';  
                        }                                              
                    }
                }                
            } 

I am sorry, i am unable to suggest until the complete explanation of the logic. But this code is looking to handle the tasks for MORNING and EVENING. Not handling the Unit Name and Unit Task.

It’s possible that this is using SuiteCRM’s default mechanism for dependent dropdowns.

See an explanation here:

https://suitecrm.com/suitecrm/forum/suitecrm-7-0-discussion/19487-how-to-create-an-associated-dropdown