What is the correct way to create an item fulfillm...
# suitescript
s
What is the correct way to create an item fulfillment off of a fulfillment request in suitescript? I tried to transform the fulfillment request, but that isn't allowed. I tried to transform the Sales Order, but I get
You must have at least one valid line item
on transform (not on save, it just never transforms) and I did notice that in the UI, it is also impossible to fulfill from the sales order. What am I doing wrong?
s
You can definitely fulfill from sales orders in the UI, perhaps there is nothing commited on the sales order and that is why there are no valid lines?
s
It's possible to fulfill from the SO even with Advanced Order Management turned on?
I see 2 "commit" related columns on the SO,
Commit
says "Available Qty" and
Commitment Confirmed
is blank, but I'm not sure what they mean. Also, even if I check the
Commitment confirmed
checkbox, I still cannot fulfill from the SO
e
Is the SO approved?
b
your best bet is following the documentation on Fulfillment Request
s
Yes the SO is in Pending Fulfillment and the fulfillment request is In Progress
Thank you for the documentation link! Unfortunately I've already been through it and the Fulfillment Request itself is working fine, I just can't seem to actually fulfill via SuiteScript.
b
whoops, wrong operation
what are the parameters in the url when you click fulfill from the fulfillment request
generally parameters in the url are default values that can be set in the transform
s
wow quite a few actually
&e=T&transform=salesord&memdoc=0&fftreqid=16747&whence=&inventorylocation=6&shipgroup=1
b
probably start with fftreqid
s
I'm not familiar with memdoc
b
ignore
inventorylocation might be required depending on how many locations you have on your lines
the others are generic
you might want to look at a regular fulfillment so you know which are more normal
s
ok thanks, I'm assuming
fftreqid
is the exact field name i need for the defaults
Unfortunately adding that default didnt fix it 😕
b
try adding the rest of the parameters
s
i did and it broke lol one of them is not allowed to be defaulted I guess
b
one by one, not all at a time
s
but interestingly the fftreqid is before the whence statement does that matter?
b
it shouldnt be
s
im not supposed to use the fftreqid as the create from ID in the transform am i?
b
share your code\
s
Copy code
itemFulfill = record.transform({
                        fromType: record.Type.SALES_ORDER,
                        fromId: origId,
                        toType: record.Type.ITEM_FULFILLMENT,
                        isDynamic: true,
                        defaultValues: {
                            fftreqid: fftreqid
                        }
                    });
origId being the internal ID of the SO, and fftreqid being the internal ID of the FR
b
i wouldnt be fancy at this point and would be hardocing the ids
the fromId should be whatever the id parameter is in the url
s
i tried that too lol
b
if you are using line level shipping, then the shipgroup is mandatory
im not sure what the inventorylocation is for, but that would be something i add in
s
wouldn’t you want to fulfill from the fulfillment request?
b
the url used suggests its from the sales order
s
shipGroup added to the defaults wouldnt let it transform, but I also dont have line level shipping enabled and inventorylocation also seemed to break it but maybe im doing it wrong
s
1. Go to Transactions > Sales > Manage Fulfillment Requests (Administrator). 2. Click View next to the fulfillment request you want to fulfill. 3. Click Fulfill. The Item Fulfillment page appears.
s
Unfortunatley thats how it works inthe UI but not in suitescript
s
but when you click fulfill from the FR, is the URL different?
s
thats where the URL is from
s
Have you tried using record.transform with FROM rec being the FR and to REC being the IF?
s
cant fulfill from the SO page for some reason
not sure what you mean
s
record.transform is not ‘entirely’ documented..
s
how would I change the code that I posted above?
s
Change the
fromType
to record.Type.FULFILLMENT_REQUEST and use its internalid
s
thats not an allowed transform
sadly
s
did you get an error when you tried it?
I know the docs don’t have it listed as valid..
s
yes i actually had that initially
s
darn.
oh, try adding the entity to the defaultValues on the Transform..
s
i know right haha it would make so much more sense
how so
s
defaultValues: {entity: soEntity}
s
with which transform? so like load the SO?
s
Usually when no items are added, it’s because the entity or subsidiary isn’t specified…
I am looking at docs and I don’t see an option for setting the entity on the IF, but you could also try setting the customform parameter.. just to be sure it’s using the correct form.
I know all of this should ‘just work’ on a transform.. I’m just throwing out a few ideas which have caused problems in the past..
b
Copy code
require(["N/record"], function (record) {
  record
    .transform({
      fromType: "salesorder",
      fromId: "11",
      toType: "itemfulfillment",
      defaultValues: { fftreqid: "12" },
    })
    .save();
});
worked for me, but i dont have an inventorylocation parameter
s
hmm
I'll retry with exactly the hardcoded params I guess
Ok I must have had something wrong in the default spelling, because I got it to import if it has the inventory location. Thanks so much! (now i just have to get the inventory location without hardcoding it haha)
b
tell me if you figure out where the inventorylocation comes from
💯 1
s
will do lol
I'm using the
location
field "Fulfillment Location" from the Fulfillment Request. I think that works correctly.