This one gives the same error too `POST .../record...
# suitescript
m
This one gives the same error too
POST .../record/v1/itemFulfillment
This is the payload:
Copy code
{
  "orderId": 14719,
  "orderType": "salesorder",
  "externalId": "rec067bZb4j9KOEXS2",
  "createdFrom": {
    "id": "14719"
  },
  "entity": {
    "id": 7429
  },
  "item": {
    "items": [
      {
        "itemReceive": true,
        "itemFulfill": true,
        "line": 1,
        "orderLine": 1,
        "item": {
          "id": "333"
        },
        "quantity": 1
      }
    ]
  }
}
b
there is no item line with the line id of 1
which means you are trying to add a new line
you cant add new lines to item fulfillments, hence the error
m
I tried many things, and all of them produced the same error. I tried to set line to zero, and tried to remove it. The weird thing is, this works just fine with the transform endpoint:
Copy code
{
  "item": {
    "items": [
      {
        "item": {
          "id": 333
        },
        "orderLine": 1,
        "quantity": 1,
        "itemFulfill": true
      }
    ]
  }
}
b
makes sense, you didnt try to set the line field
so the orderLine is used as the key
one of the more important things to know when working with netsuite records is that the line field is a line id
it it not a line sequence number
the first line is not required to have an id of 1
its especially true on transactions like item fulfillments, where each item line sublist row represents multiple accounting impacts
each of those accounting impacts will have its own line id
m
But why the same payload that works with the transform endpoint doesn't work with the PUT /itemFulfillment endpoint? I tried to remove the line field and it didn't work with PUT /itemFulfillment. I still can't see the issue.
b
put and post do different things
when you are updating the item fulfillment, there are line ids, when you are creating it, there arent
m
The POST endpoint doesn't work too even if you removed line ids.
b
same problem
it cant match to an existing line (in this case because there are no keys)
so it tries to add a new line
you need to master Working with Sublists before you have any chance here
m
I still can't see the issue.
> put and post do different things PUT should do what POST does according to the docs. (if the record is new)
b
when you are doing a transform, there are lines to match to
from the sales order you are transforming from
when you are doing the create, there are no lines
m
I feel we both are missing something here.
b
you havent shared the rest of the request body, but that sounds like there are no items
m
Copy code
{
  "orderId": 14719,
  "orderType": "SalesOrd",
  "externalId": "rec067bZb4j9KOEXS2",
  "createdFrom": {
    "id": "14719"
  },
  "entity": {
    "id": 7429
  },
  "subsidiary": {
    "id": "1"
  }
}
Endpoint:
POST https://<account-id>.<http://suitetalk.api.netsuite.com/services/rest/record/v1/itemFulfillment|suitetalk.api.netsuite.com/services/rest/record/v1/itemFulfillment>
b
that would be because there are no items
m
I can't really judge if you are serious or joking.
b
your first set of errors were related to invalid sublist operations
which were attempts to add new lines
your next error was related to no items, because you can cant add an item fulfillment with no lines
although that second class of error is fairly self explanatory
the first set of errors tend not to make sense unless you understand how keys work
m
You said when you are doing the create, there are no lines... and this is wrong, that's why I sent the screenshot. Then you said it is because there are no lines. The first error doesn't make sense as the last one, none of it makes sense and it is a shame that a company like Oracle can't produce an API that works as expected or to provide straight forward docs. Anyway, it is understandable. Appreciate taking time to help (none of what I said is about you personally in any way)
b
still sounds like you dont understand how netsuite treats lines
in the web services, it needs to determine if you are trying to change an existing line or add a new one
and does so via keys
if a key matches an existing line then it will update, if not, it will add a new line
every single time you had the invalid sublist operation, the item line you had in the request didnt match an existing line
m
Isn't
orderLine
enough for matching? It works in the transform endpoint just fine. Is there a specific key I should use? If you used these endpoints before, POST or PUT, I would appreciate it if you could share what the payload looks like.
b
there is no existing line on an item fulfillment to match to on create
in contrast, the transform does have exiting lines to match to since its transformed from the sales order