Custom Script to set a Default Field According to a Different Field's Input

Hi All,

I’m fairly new to custom scripts.

Okay so here is the problem:

We use the Production Plan Doc to create the work orders for our production. We have a number of number of sub-assemblies that work orders are created for. This means that the Work Orders that are automatically created need to have different target and wip warehouses. I currently use the the check boxes on the side of the work order list view and the edit button to update target and wip warehouses (sending different sub assemblies to their desired warehouses).

This is very time consuming as there is a Production Plan for each type of product produced (for tracking purposes) and we produce many different products.

I have written a custom script to automatically set the wip and target warehouses (it looks at the item name, all sub assemblies the go to the same warehouse have the same prefix, and runs a conditional statement that sets the warehouses based on this prefix) BUT it only runs when I open the actual Work Order Doc. I would like it to load without physically going into the doc (so I can just use the check boxes on the side of the listview and submit all work orders with out individually going into each one).

If anyone has a solution I would appreciate it.

I have tried changing the trigger from refresh, to onload, on submit and even on a change of field value (I thought this would work because the you can change a field from the list view) BUT it only seems to update those changes when you go into the doc? i.e. I submitted the work orders from the list view, it says the warehouses have been changed correctly but has an update button in the corner of the Work Order Doc but when I click it a message pops up: ‘Not allowed to change Work-in-Progress Warehouse after submission’. The only conclusion I can draw from this is that my custom script is not running until after the submit (that I initiated in the list view) has already occurred.

It would be better if you record a video about your problem.

I will try provide a video that portrays the issue in a concise manner.