I've got a question on a Transform Sales order to ...
# suitescript
m
I've got a question on a Transform Sales order to Item Fulfillment where we have multiple locations. I've used the SuiteAnswers 43798 as a starting point, but I'm having some trouble with the fulfillment line location. The initial code is:
Copy code
var lineCount = fulfillmentRecord.getLineCount('item');
for (var i = 0; i < lineCount; i++) {
    fulfillmentRecord.setSublistValue('item', 'location', i, 1);
What I need to do is get rid of the hardcode location of '1' in line 3 Would this work, if I put it above the loop?
Copy code
var orderLocation = Record.getValue({
     fieldId: 'location'
 });
And set the sublist line as
Copy code
fulfillmentRecord.setSublistValue('item', 'location', i, orderLocation);
I'm kind of stumped!
s
I've never tried to have multiple locations on a single fulfillment, shouldn't the fulfillment line be inheriting the location from the sales order line?
m
Our sales orders always ship from the same location per order. It's just that '1' is our West Coast and '2' is east coast. I can solve it by doing 2 scripts and deploying separately; I was just wondering if it could happen dynamically.
s
Not sure I understand, if the location is on the sales order, then when you transform the sales order, the item fulfillment gets the location from the sales order.
m
Yes, but on the setSublistValue, it has 'location' as 1. That's a hardcode. But... I have isDynamic set to False. Maybe True would work? Or just remove that line-by-line loop?
s
Are you not using record.transform I assume? I'm saying I am not sure why you are setting the location at all.
d
I'm pretty sure Itemfulfillments do not support multi-locations. When you reference SuiteAnswers 43798, how do I actually find that article?
d
Odd, that article is about Schedule Script Type. Ok.
b
im with team nonssense on this one, I dont know what combination of settings allows location on fulfillments to be changed
s
@Mark C the isDynamic trigger would not affect that, it mostly just changes the way you have to interact with the record
m
No worries. I'll do plan b and just set two scripts (and they are scheduled - it's to bulk fulfill at certain intervals during the day) Thanks all!
b
The simpler fix is to remove the location setting code. Unless you set locations when you manually fulfill from the sales order
m
I tried that and it failed. 😞
I ended up just setting up 2 scripts, one for each warehouse.
b
After minor experimentation, setting the
Fulfill Based on Commitment
preference to
Allow Uncommitted
allows you to set locations on fulfillment lines
👍 1
m
I was able to get location out of the line. I don't know why it failed out earlier; I probably had a typo after staring at this the past few days.
Thanks again everyone!