I need to customize the BOM , only the items which pass certain condition should appear when I click the add item field in the BOM , any ideas ?
In detail : I have products with certain chemical composition , only the raw materials with the same chemical composition as that of the item_code (product) should get displayed in the bom item select field .
I mean I should filter the items based on certain condition .
Thank you for your swift response Sir , I am able to achieve something with the below script , those items which has carbon value 12 will get displayed .But what I want is those items which has carbon value less than or equal to the item I selected in the item code should be displayed . Please help
Where do you keep the percnt _ carbon_min fields? That script should work if the percnt_carbon_min field is a custom field for item. It should make sure that any items added to the BOM are <= the percnt_carbon_min of the item the BOM is made for.
Sir , thanks a lot for quick response , Yes sir ,percnt_carbon_min is a custom field in item doctype .I do have this percnt_carbon_min field in item doctype above the brand field .
My concern is raw material and product both have this field percnt_carbon_min , if I select the product , only the raw materials with the same value or less than that of percnt_carbon_min should display . I copied your script and pasted it in BOM manufacturing custom script location and reloaded , cleared cache several times , but it filters nothing , please help
I even tried removing ‘’<’’ to ensure only the products with the same value of percnt_carbon_min as that of the item_code i selected will display , but it displays everything , it does not filter anything . Please help .
Sir , I understood one thing , the items going to get filtered is in a child table , so I copied your script in both parent and child custom script location , even after that the problem persists . To overcome this i created a field in BOM with the name item_code , even that didn’t work. Perhaps the filter could have got applied but should the refresh function be added here ?
For the ease of reference and to have clarity , I have put the field names here ,
BOM field name - item
BOM ITEM child table going to get filtered - field name - item_code
Should the script be modified for a child table ? If so the case will be that the control field will be in the parent doc and items going to get filtered will be in child table ? Could you please guide me on this with the script ? Also can you guide me to display only the raw materials when adding BOM
Sorry, I had a small bug in my code. I also added an additional filter that requires that the Item Group be a Raw Material. If you indicate that it is a Raw Material somewhere else, you’ll need to change the filter to match your requirements.
Thanks a ton for the script and taking time to guide me , but the script is not working sir , I even copied the script in BOM-item child table location as well but it is not working . Sorry if I had disturbed you , sir could you please help me with the script when you are free
For the first item being added to bom , it wont work .Sir the script is working if I add one more item , How to add refresh function here ? Thanks a lot for the script. And one more issue , I went on adding my next filter , now the filter is taking the second script and it neglects the first script , also the product for which BOM is being prepared is also getting displayed in the drop down , please guide me on this
Sir thanks a ton for replying , an empty child is already created when I open the BOM , it is not completely empty . I do have around 24 filters to be applied , percnt_carbon_min , percnt_man_min, percnt_carbon_max , percnt_man_max, and so on , So i tried to add the second filter , this is my script
It looks like you have too many brackets: }. To get more information about the error, you should be able to click a link on VM268:266 which will take you to the code surrounding the error. That will show you what code is causing the error. Paste it here if you need help figuring it out.
Also, I think you need square brackets around the fieldnames: "fieldname": ["percnt_carbon_min","percnt_carbon_max"].
Sir thank you so much , the script now works like a charm , but does not work for the first instance , only the second row is getting filtered , is there any way to add refresh function here ? Thanks a lot for this awesome script .