Changing a field to mandatory after selecting an option from a drop down field

Hi good day!
Im new in this forum, Currently working on a project using erpnext, To make a certain task more efficient changing a field type to mandatory or to read only after selecting an option from a drop down field would be a very effective way to avoid wrong input errors. Looking forward for your help. Thank you.

Nikko Z.

Hi @NikzurNext,

You will need t o write the trigger on select field and compare the option values, then accordingt to your requirement you can change the fields property using following methods in client script

cur_frm.toggle_display("fieldname", true) to hide or unhide field
cur_frm.toggle_enable("fieldname", true) to make field readonly or editable
cur_frm.toggle_reqd("fieldname", true) to make field madantory

Thanks, Makarand

5 Likes

Hello @makarand_b

Thank you so much. I’ll try to apply this and post here the result. Highly appreciated. Thanks. :smile:

Hi @makarand_b,

The code worked smoothly. By setting the default to mandatory the code worked more efficient.

Thank you.
My regards,
Nikko Z.