Creating a Vendor Bill from an Item Receipt using SuiteScript

in , , July 31st, 2024

A Basic Record Transformation

This article will show how to recreate the auto-bill functionality of an item receipt in SuiteScript and explain how I discovered this solution.

Recreating item receipt auto-bill functionality in SuiteScript

Utilize N/record’s transform function as such:

const billRecord = record.transform({
  fromType: record.Type.PURCHASE_ORDER,
  fromId: itemReceipt.getValue("createdfrom"), // itemReceipt had been initialized
  toType: record.Type.VENDOR_BILL,
  defaultValues: {
    itemrcpt: itemReceipt.getValue("internalid")
  }
});
// do what you need to do to the new bill record
billRecord.save();

How I Discovered the Solution (Aid for Similar Troubleshooting)

This section might be useful if you have to make your own solution that does a transform similar to this scenario.

Exploring Page Parameters

Before figuring out that a record.transform is needed, I clicked “Bill” on the Item Receipt, which does not save a new bill record at the moment but fills one out with the necessary details. Next, we explored the URL parameters of the page:

The parameters “transform=purchord,” “itemrcpt=210274,” and “id=207409” can be found in this URL.

Transform Parameter

First, the “transform” parameter suggested that record.transform might be needed. Second, the creation of a vendor bill from the purchase order, not the item receipt, was confirmed through the URL and cross-referencing with the Supported Transformation Types table on SuiteAnswers’s “record.transform(options)” page, which lists Purchase Order to Vendor Bill as a valid transformation but not Item Receipt to Vendor Bill.

ID Parameter

Next, by exploring the “xml=t” page of the item receipt, we figured out that “id=207409” refers to the purchase order record that the item receipt is created from.

Item Reciept Parameter

Finally, “itemrcpt=210274” seems to obviously connote the item receipt, but whether or not that would be an accepted variable was in question because vendor bills created from item receipts do not have an “itemrcpt” field. However, if you open the “xml=t” page for a newly created vendor bill from the item receipt page before it is saved, there is indeed an “itemrcpt” field with this value.

The last thing that had to be done to confirm this was plugging the “itemrcpt” value in the default values parameter of the record.transform, and it happened to all work as it should, correct with the quantity values from the item receipt, not necessarily the same values from the purchase order.

Author: John Baylon


Get stuck in a step during this article?

We like to update our blogs and articles to make sure they help resolve any troubleshooting difficulties you are having. Sometimes there is a related feature to enable or field to fill out that we miss during the instructions. If this article didn't resolve the issue, please use the chat and let us know so that we can update this article!

 
 

Want to keep learning?

Our team of NetSuite professionals has written articles on a wide variety of NetSuite topics, from SuiteCommerce tips, to recommended NetSuite solutions, to available support services, and more! 

Your cart