'Custom field not sourced to work order SuiteScript 2.0
Here is my code snippet for creating a work order:
var TO = record.create({
type: 'workorder',
isDynamic: true
});
TO.setValue({
fieldId: 'customform',
value: '80'
});
TO.setValue({
fieldId: 'subsidiary',
value: 1
});
TO.setValue({
fieldId: 'location',
value: 1
});
TO.setValue({
fieldId: 'assemblyitem',
value: item
});
TO.setValue({
fieldId: 'quantity',
value: qtytobuild
});
var newWO = TO.save({
ignoreMandatoryFields: true
});
The work order is created with the right quantity to build. The component list (item sublist) is correct in terms of items and quantities. So nothing to worry about there. But, I have a custom field on the item record that is sourced to the work order component sublist (to a transaction line field). It works fine if I manually create the work order, but if I do it with my script it is not sourced. I have tried to set isDynamic:false with the same result.
Does anybody have an idea of what could be causing this?
Solution 1:[1]
Try setting the enableSourcing option to true on the save (this defaults to false.
var newWO = TO.save({ ignoreMandatoryFields: true, enableSourcing: true });
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | VanMan |
