I need dropdown options for sales stage field in opportunity not to see for certain users

Hi All,
I had a field name in Sales Stage label{custom_stages}fieldname in deal(opportunity) doctype i need sales user not to show “Closed Won”, “Closed Lost” options for sales user but i need to show for system manager


Thanks in Advance

frappe.ui.form.on('Opportunity', {
    onload: function(frm) {
         
        if (frappe.user.has_role("System Manager")) {
            
            return;
        }
        else if (frappe.user.has_role("Sales User")) {
           
            frm.fields_dict['custom_stages'].df.options = frm.fields_dict['custom_stages'].df.options.split('\n').filter(function(option) {
                return option !== "Closed Won" && option !== "Closed Lost";
            }).join('\n');
            frm.refresh_field('custom_stages');
        }
    }
});

By using this script you can hide options

1 Like