Custom Field - Visiblity Depends on what's in child table

I’m trying to make a custom field in the Quotation doctype where the visibility depends on what’s in the item child table.

I would like the field to show if any items in the item child table have an item_group value of “Optional”.

Is this possible? Any help would be appreciated.

@Dbone use this in depends_on

eval: cur_frm.doc.items && cur_frm.doc.items.length && in_list(cur_frm.doc.items.map(function(r){ return r.item_group}), "Optional")
4 Likes

Unfortunately this doesn’t work. Custom field is always visible even with no items in the child table.

Edited

This time the field is hidden and won’t un-hide if an item from the group “Optional” is shown. Using the script also prevents me from saving the document.

@Dbone was a typo!

Haha, might have figured that out myself if I looked at it more carefully!

Works beautifully, thank you very much for your help!