When creating work orders via the UI, when you ent...
# suitescript
e
When creating work orders via the UI, when you enter the assembly item and the quantity on the header, the lines will bring in the components with the correct line-level quantities. For example component A = 1; component B = 2 so on the line if the quantity = 5, each component will show the correct quantities. However, when creating work orders via script, the component line quantities show up as the original component quantities (ie A = 1; B =2). What other fields are needed on the script to have those quantities show up correctly?
c
Are you using Advanced Manufacturing? There's a bug somewhere in their logic that messes with quantities (at the line level) when you change values on work orders.
s
It might be the order in which you are setting header level fields; you might be changing something at the header level which is resetting those quantities erroneously (location is good example)
Oh I just saw your code block, you might need to force sync/sourcing or try in dynamic mode
e
@Sandii I did try isDynamic: true but it still didn’t work.
Thanks @creece I will check if this environment is using Advanced Manufacturing.
@Sandii the code was written by someone who used to work at Netsuite and I’m trying to figure out why it works the way it does (and not as expected). The only solution I have at the moment is to load the record after the WO is saved and then loop through the lines to correct the line quantities.
s
I have code that is doing similar stuff, and it has no problems as long as quantity is the last thing I set (it's also in dynamic mode which is why I suggested that)
e
Yep I checked some old code that I had that created work orders and it looks the same so I’m wondering what’s different in this environment.
s
You could try swapping item/location since those are the 2 things taht would determine what BOM it should use if they have advanced manu
c
im pretty sure you're running into what I was running into with the quantities changing which is a defect and not on you
s
I see a comment in our code that we explicitly set
location
twice because it stopped working, so it makes me think that setting location after item might fix your problem
c
Order only matters if its in the UI or dynamic mode.
👍 1