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?