0

I am newbie to NetSuite and wanted to show vendor names in specific format while displaying. Currently each vendor has auto-generated id with some prefix e.g.

ABC0001
ABC0002
ABC0003

These vendors are then shown as a sublist in other pages as following:

ABC0001 Mr. Vendor A
ABC0002 Mr. Vendor B
ABC0003 Mr. Vendor C

I want to show vendor name as Name only, without the id in sublists like below:

Mr. Vendor A
Mr. Vendor B
Mr. Vendor C

How is that possible? Currently I tried to use following SuiteScript, but its not working:

define(["N/record"], function (record) {
  /**
   *@NApiVersion 2.0
   *@NScriptType ClientScript
   */

  function pageInit(context) {
    var itemRecord = record.load({
      type: record.Type.INVENTORY_ITEM,
      id: context.currentRecord.id,
      isDynamic: false,
    });

    var lines = itemRecord.getLineCount({ sublistId: "itemvendor" });

    for (var i = 0; i < lines; i++) {
      var vendorName = itemRecord.getSublistText({
        sublistId: "itemvendor",
        fieldId: "vendor",
        line: i,
      });

      var parts = vendorName.split(" ");
      parts.shift();
      vendorName = parts.join(" ");

      itemRecord.setSublistText({
        sublistId: "itemvendor",
        fieldId: "vendor",
        line: i,
        text: vendorName
      });
    }

    itemRecord.save();
  }

  return {
    pageInit: pageInit,
  };
});

Any idea what am I doing wrong here?

Haris ur Rehman
  • 2,593
  • 30
  • 41

1 Answers1

1

You want to change the "entityid" field on the Vendor itself not in the Item sublist. So probably when the vendors are saved you will want to update the entityId to display whatever you want it to show up as in LOV's.

You may have to change some preferences depending on how your Auto Generated Numbers are setup. Go to Setup > Company > Auto-Generated Numbers and make sure that you are allowing override on the vendors.

Nadav Julius
  • 301
  • 2
  • 16