I have a custom field of type Select in the Production Order form with two options. Depending on what I select, I can use a specific group of items to manufacture.
The problem is, how can I manage this? I try to use a conditional statement in the main JS file like this, but it does not work:
Thanks @nabinhait for your response , but it doesn’t work in both JS file and Custom Script.
The idea is:
I have two groups of items: Raw material and Compounds.
When I make a Production Order, I have to select a type of item and, depending on what I selected, in the production_item field you only see the items that are in this group.
I tried to use onload function in both JS file and Custom Script and it still does not work.
It’s “funny” that, although I’m not using any filter and I do not see a filter in JS / PY files, the production_item field to select the item to be manufactured is being filtered by an item group by default, an item group that I created.
@schilgod, exactly, where can I view the logs that refer to the loading of that function?
I put console.log(‘testing’); and only this is returned when I click on New button to create a Production Order:
SyntaxError: Invalid or unexpected token
at Class.setup (http://192.168.1.54:8080/assets/js/form.min.js?ver=1532940019.0:2693:18)
at _f.Frm.setup (http://192.168.1.54:8080/assets/js/form.min.js?ver=1532940019.0:172:22)
at _f.Frm.refresh (http://192.168.1.54:8080/assets/js/form.min.js?ver=1532940019.0:446:9)
at Class.load (http://192.168.1.54:8080/assets/js/form.min.js?ver=1532940019.0:87:33)
at http://192.168.1.54:8080/assets/js/form.min.js?ver=1532940019.0:82:7
at Object.with_doc (http://192.168.1.54:8080/assets/js/desk.min.js?ver=1532940019.0:5505:4)
at Class.show_doc (http://192.168.1.54:8080/assets/js/form.min.js?ver=1532940019.0:65:16)
at http://192.168.1.54:8080/assets/js/form.min.js?ver=1532940019.0:24:8
at Object.with_doctype (http://192.168.1.54:8080/assets/js/desk.min.js?ver=1532940019.0:5444:17)
at Class.make (http://192.168.1.54:8080/assets/js/form.min.js?ver=1532940019.0:20:17)
The only changes I made to the code were to change Type 1, Type 2, Group 1 and Group 2 by their real names, and I am sure there are no errors with types and groups.
Metrics
There are 2 functions in this file.
Function with the largest signature take 1 arguments, while the median is 0.5.
Largest function has 7 statements in it, while the median is 4.
The most complex function has a cyclomatic complexity value of 3 while the median is 2.
One undefined variable
12 frappe