Categorizing select type fields

Hi, Is there a script for categorizing field? Like for example I have a field that is named “Requested by” in the requested by field I want to put a select type and put names on it with there designation.

Here is the example of the select type field:

Sales Department
emp01
emp02
emp03
Technical Department
emp1
emp2
emp3
Admin Department
empp1
empp2
empp3

I dont think its available… but see if below mentioned approach works for you…

create one more field called ‘Department’ of type ‘select’ and list departments… let the user first select the departmet and then in employee field you can filter employees based on the department choosen…

2 Likes

@kelscey90 , As per @Basawaraj_Savalagi suggession you have to first select department and then write a script for showing employees department-wise . Refer following link for return query on employee -

-Regards, Priya

1 Like

@Basawaraj_Savalagi, This is a good one! Thanks! Btw. Why does the “if” not working? my date is not automatically inserted when I create a new document.

Here’s the code I tried but isn’t working.

frappe.ui.form.on(“Stock Request”, “onload”, function(frm, cdt, cdn, doc, dt, dn){
frm.add_fetch(“item_code”, “description”, “description”);
frm.add_fetch(“item_code”, “item_name”, “item_name”);
frm.add_fetch(“item_code”, “stock_uom”, “stock_uom”);
frm.add_fetch(“item_code”, “item_group”, “item_group”);
frm.add_fetch(“item_code”, “brand”, “brand”);
frm.add_fetch(“requested_by”, “Non-Alcon Personnel”, “non_alcon_personnel”);
if (frm.doc.date_requested < get_today()) {
msgprint(__(“You can not select past date in From Date”));
validated = false;
}
})

@priya_s Thank you! Now it’s easier! :smiley:

1 Like