Hi guys, I am struggling with a small problem here...
# suitescript
d
Hi guys, I am struggling with a small problem here on a script and I am not sure why or what is exactly causing the problem. The goal of this script is to set the price level of an item by script (To be combined later into larger functionality) When executing the script I receive no errors, however, no modification is made to the items price. For the sake of debuging, I have limited my search to a single item.
Copy code
var itemsearch = search.create({
   type: "item",
   filters:
   [
   	  ["internalid","is", "131120"],
   	  "AND",
      ["vendor","is","572"], 
      "AND", 
      ["ispreferredvendor","is","T"], 
      "AND", 
      ["isinactive","is","F"]
   ],
   columns:
   [
   		search.createColumn({name: "internalid"}),
    	search.createColumn({name: "entityid", join: "vendor"}),
     	search.createColumn({name: "vendorcost"}),
     	search.createColumn({name: "custitem_cc_brand", sort: search.Sort.ASC})
   ]
});
itemsearch.run().each(function(result){
	    var sublist = "price";
		var item = record.load({type: 'inventoryitem', id: result.getValue("internalid"), isDynamic: true});
		item.selectLine({sublistId: sublist, line: 0});
		item.setCurrentSublistValue({
			sublistId: sublist,
			fieldId: "price",
			value: "0"
		});
		item.commitLine({sublistId: sublist});
		console.log(item.save());
});
c
https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2018_1/script/record/inventoryitem.html There is no "price" sublist.. only "price1"/"price2" etc.. that may be your issue. Code seems ok otherwise.
d
I will try it with price1, thank you.
b
you may also want to lookup
Pricing Sublist / Pricing Matrix
in the help center. Item pricing is one of the the harder things to work with
d
I am now running into the following error
Copy code
Uncaught TypeError: Cannot read property 'isMultilineEditable' of null
Here is the code:
Copy code
itemsearch.run().each(function(result){
	    var sublist = "price1";
	    var itemid = result.getValue({name: "internalid"});
	    console.log(itemid)
		var item = record.load({type: 'inventoryitem', id: itemid, isDynamic: true});
		console.log(item.getValue("id"));
		item.selectLine({sublistId: sublist, line: 0});
		item.setCurrentSublistValue({
			sublistId: sublist,
			fieldId: "price",
			value: "1"
		});
		item.commitLine({sublistId: sublist});
		console.log(item.save());
		return true;
});
b
include a screenshot of what your item pricing looks like
d
message has been deleted
b
you have multiple price levels enabled
you need to use the matrix related methods
see the help guide topic i sent you earlier
d
😞 I was trying to avoid having to learn that
b
you have the second easiest version of the pricing
multiple currency and quantity pricing are not enabled
that means there isnt price1,price2, and so on
there is only the price sublist
it also means that there is only 1 matrix column
that means that the column key is always 0
that means you only need to find the sublist line that has the matching price level
usually using findSublistLineWithValue
if you are lazy and don't want to bother finding the price level line number, you probably want to set the price of the first line, item.setMatrixSublistValue({ sublistId: 'price', fieldId: 'price', column: 0, line:0, value: 3.14 });