Hi everyone,
Attached are two scripts, both of which one of their functions is to create an Inventory Adjustment for items to be moved/removed.
They both use similar if not identical ways of creating their Inventory Adjustments, along with the same Location, Subsidiary and Account, but the Item Removal SS is throwing an unexpected error when trying to save its IA.
Testing:
I would think it might be something to do with the items I'm trying to remove? But I have checked to make sure none of the items are inactive or have the wrong inventory and have made sure to skip any in my script if they don't contain a bin location. I have separated the IAs into batches of 10 items and still none of them save, so I'm doubtful the issue is to do with the items.
const BATCH_SIZE = 10;
let processedItems = new Set();
for (let i = 0; i < searchResults.length; i += BATCH_SIZE) {
const batch = searchResults.slice(i, i + BATCH_SIZE);
const batchNum = Math.floor(i / BATCH_SIZE) + 1;
try {
const adjustmentId = createInventoryAdjustment(batch);
The deployment uses an Admin Role.
I have tried adding the default status value of Good to the inventory detail (shouldn't have been an issue anyway) but this has had no effect.
invDetail.setCurrentSublistValue({ sublistId: 'inventoryassignment', fieldId: 'status', value: 1 });
These are all Inventory Items, not Lot nor Serialized.
The bins are not inactive.
I have tried assigning it a date (even though this should be default to today).
I have tried creating an IA manually with the same items, quantities and locations with one of the batches of search results and encounter no issues.
What could I be missing?
I'm a bit worried that this question seems to get asked a lot from the searches I've done, yet has very few answers.