Change linked field options based on retrieved multilevel bom items

Hello!
I have fields for Production Order and BOM. What I want to do is fill in the BOM linked field with the PRO linked BOM and its multilevel BOM’s. Eg. If PRO 1 is created from Bom1 and Bom1 is made up of Bom2 and Bom3, the BOM field should show bom1,bom2, and bom3. If bom2 and bom3 are also multilevel boms, then those boms under bom2 and bom3 should also be in the linked field.

I made a recursive python function to return an array of the boms to be included as options. The problem is, I have no idea on how to set this as the BOM field options. :sweat_smile:

I already tried :
frappe.meta.get_docfield(frm.doctype, "bom", frm.docname).options=options.join("\n")

and it returns an error saying “Doctype all-the-array-entries not found”, “resource does not exist”.

Any ideas on how to make this work?
Thanks! :slight_smile:

Current workaround:

Changed the BOM linked field to a select field. After I did, frappe.meta.get_docfield(frm.doctype, "bom", frm.docname).options=options.join("\n") worked. :slight_smile:
(Disadvantage : No more BOM linking. sigh)

I’m still open to suggestions. And those who need the python script for the recursive multilevel bom retrieval, just ask and I shall post. :slight_smile:

Hi, I am not sure that it is a good way but you can use HTML field and add to the option’s part links. I hope you understand what I meant.

1 Like

@SwitsolAG, I think I get what you mean. I haven’t tried HTML fields yet but I’ll read more about it and try to figure it out.

Thanks! :slight_smile: