I have a RESTlet, where I start with an invoiceID ...
# suitescript
e
I have a RESTlet, where I start with an invoiceID and find the sales order, then find the item fulfillment and then find the items. But can I go the other way. From an itemID, can I find the sales order? Do I have to use search in that case?
b
doesnt really sound sane
items can be on multiple sales orders
you need something unique to a sales order to find that particular sales order
e
The items have a unique id
@battk In the sublist
inventoryassignment
of Item-fulfillment, I can see the
inventorynumber
But is it possible to search for the inventorynumber ?
b
if you are doing a search on the item fulfillment, then you want to use the inventory detail join
e
@battk I am struggling with the search API. Do you think it could be possible to use records ? Something like:
Copy code
const objRecord = record.load({
        type: record.Type.INVENTORY_NUMBER,
        id: 'bcy32scy',
    });
But not use id for lookup, but inventorynumber etc?
b
Would require internal id
Are you able to make the search in the ui?
e
No, I can't search for it in the UI. But I find it when I do this:
Copy code
search.create({
    type: 'inventorynumber',
    filters: ['inventorynumber', 'is', 'bcy32scy'],
    columns: ['inventorynumber']
  }).run()
    .each(function(result) {
      log.debug(result.id);
      return true;
    });
b
if you are searching by the number of the item number, then you probably want to use the item number join instead
use the inventory number column of the item number for your filter
i heavily recommend knowing how to make the search in the ui before trying to make it in script
the ui presents nice lists of available filters, and can show you the values in the columns
e
@battk I must be miss-understanding this completely. I just want to find the item-fulfillment or sales-order that contains the item with serial-number: bcy32scy.
b
First step to a solution should be making the search that does what you want in the ui
In your case i would pay extra attention to the type of filter used. A filter like the number from an inventory detail uses select options, which suitescript represents as internal id numbers
Try to find a filter that is represented as a free form text input if you don't want to lookup the internal id that represents bcy32scy