How to show/hide values in a dropdown based on user security group?

Hi,

I was able to show/hide values in status dropdown using legacy method. So when a sales user logs in he will see only ‘draft’, ‘sales_review’. But for this to work I need to disable the angular frontend for the module. I don’t want to change the UI to leagcy. How can I show/hide dropdown values in angular frontend?

/var/www/suitecrm/public/legacy/custom/include/MPC_dropdown_functions.php

<?php
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

function get_status_list_by_security_group()
{
    global $current_user, $app_list_strings;

    // Debug log to confirm function is being called
    LoggerManager::getLogger()->fatal('get_status_list_by_security_group called');

    // Find your actual dropdown list name - check vardefs to get the correct name
    // Common patterns: mpc_job_requirements_status_list, job_requirement_status_list, etc.
    $originalDropdown = 'mpc_job_requirements_status_list'; // UPDATE THIS TO YOUR ACTUAL LIST NAME

    // Fallback: try to find it dynamically
    if (!isset($app_list_strings[$originalDropdown])) {
        // Try different variations
        $possibleNames = array(
            'mpc_job_requirements_status_list',
            'job_requirements_status_list',
            'status_list',
            'mpc_status_list'
        );

        foreach ($possibleNames as $name) {
            if (isset($app_list_strings[$name])) {
                $originalDropdown = $name;
                break;
            }
        }

        // Last resort: log all dropdown lists to find the right one
        if (!isset($app_list_strings[$originalDropdown])) {
            LoggerManager::getLogger()->fatal('Available dropdowns: ' . implode(', ', array_keys($app_list_strings)));
            // Return empty array - don't fail
            return array('' => '');
        }
    }

    $fullList = $app_list_strings[$originalDropdown];

    LoggerManager::getLogger()->fatal('Original list count: ' . count($fullList));

    // Admin sees everything
    if (!empty($current_user->is_admin)) {
        LoggerManager::getLogger()->fatal('User is admin - returning full list');
        return $fullList;
    }

    // Get user's security groups
    require_once('modules/SecurityGroups/SecurityGroup.php');
    $securityGroups = SecurityGroup::getUserSecurityGroups($current_user->id);

    if (empty($securityGroups)) {
        LoggerManager::getLogger()->fatal('No security groups - returning full list');
        return $fullList;
    }

    $groupNames = array_column($securityGroups, 'name');
    LoggerManager::getLogger()->fatal('User groups: ' . implode(', ', $groupNames));

    // Define allowed statuses per group
    $statusConfig = array(
        'Sales' => array('draft', 'sales_review'),
        'Finance' => array('submitted_to_finance', 'finance_review', 'finance_changes_requested', 'finance_approved'),
    );

    // Collect allowed statuses
    $allowedStatuses = array();
    foreach ($groupNames as $groupName) {
        if (isset($statusConfig[$groupName])) {
            $allowedStatuses = array_merge($allowedStatuses, $statusConfig[$groupName]);
        }
    }

    $allowedStatuses = array_unique($allowedStatuses);

    if (empty($allowedStatuses)) {
        LoggerManager::getLogger()->fatal('No allowed statuses configured - returning full list');
        return $fullList;
    }

    LoggerManager::getLogger()->fatal('Allowed statuses: ' . implode(', ', $allowedStatuses));

    // Filter the list - MUST return an array with key => value pairs
    $filtered = array();
    $filtered[''] = ''; // Always include empty option

    foreach ($fullList as $key => $label) {
        if (in_array($key, $allowedStatuses)) {
            $filtered[$key] = $label;
        }
    }

    LoggerManager::getLogger()->fatal('Filtered list count: ' . count($filtered));
    LoggerManager::getLogger()->fatal('Returning: ' . print_r($filtered, true));

    return $filtered;
}

/var/www/suitecrm/public/legacy/custom/Extension/modules/MPC_Job_Requirements/Ext/Vardefs/custom_status.php

<?php
$dictionary['MPC_Job_Requirements']['fields']['status']['function'] = array(
    'name' => 'get_status_list_by_security_group',
    'include' => 'custom/include/MPC_dropdown_functions.php'
);

// Make sure the type is 'enum'
$dictionary['MPC_Job_Requirements']['fields']['status']['type'] = 'enum';

I found this in the document. Update field value based on a backend calculation :: SuiteCRM Documentation . But this works based on the value of another field. Is there anyway we can make this work on page load itself instead of depending on another field?