get invoice number in fulfillment
# ask-stanley-ai
i
get invoice number in fulfillment
c
AI generated answer (using internal Slack threads):
To get the invoice number in fulfillment, you can follow these steps: 1. Load the Sales Order (SO) from the Invoice using the
createdfrom
field. This can be done using the
record.load
method in SuiteScript. 2. Once you have the Sales Order, you can search for the Item Fulfillment (IF) that has a
createdfrom
field that matches your Sales Order id. This can be done using the
search.create
method in SuiteScript. 3. If you are unable to find the Item Fulfillment id directly, you can try to get the line item value of a field called
orderdoc
from the Sales Order. This might hold the Item Fulfillment id. 4. If the above step doesn't work, then on the before load event of the invoice creation, try to get the line item value of the
line
field. There is a chance that it will contain the Item Fulfillment id + "_" + line index. Here is a sample code snippet:
Copy code
javascript
var salesOrder = record.load({
    type: record.Type.SALES_ORDER,
    id: invoice.getValue('createdfrom')
});

var itemFulfillmentSearch = search.create({
    type: search.Type.ITEM_FULFILLMENT,
    filters: [
        ['createdfrom', search.Operator.ANY_OF, salesOrder.id]
    ]
});

itemFulfillmentSearch.run().each(function(result) {
    var itemFulfillmentId = result.id;
    // Do something with the item fulfillment id
    return true;
});
****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.831761241
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.827140629
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.826077461
Please provide your feedback on this answer.