is it possible to delete a package line on an item...
# suitescript
n
is it possible to delete a package line on an item fulfillment? removeLine doesn't seem to work i get this error: You have attempted an invalid sublist or line item operation. You are either trying to access a field on a non-existent line or you are trying to add or remove lines from a static sublist.
b
hopefully you dont have to remove all of them
netsuite will try to add back a package line if you try to remove all of them
otherwise removeLine should work. keep in mind that integrated shipping methods dont use the standard package sublist
n
I want to remove package lines with empty package tracking numbers - i get that error when trying to remove a UPS package line
the sublist id is: packagesups
something of that nature, but I get that error using removeLine
b
packageups
vs
packagesups
?
n
I'll double check the spelling just to be sure but I believe it is the second one
this is what I was using: rec.removeLine({ sublistId: 'packageusps', line: j });
b
get your carrier correct,
packageusps
is not the same as
packageups
other than that, make sure you are using rec.getLineCount to make sure the sublist lines exist and that you are removing a valid line
especially if you are removing multiple lines in the naive order of smallest indexes to largest indexes
n
this is what I am trying to get - if tracking number is empty, delete line
@battk
b
dont add business logic when you are trying to see if you do something
you should only be trying to load the record, remove the first line, then save the record
if you are desperate, you can also try doing the same action in dynamic mode
n
Got it working, I couldn't use selectLine on the packages sublist
last issue is in my search filters I have this (getInput) : "AND", ["max(formulanumeric: CASE WHEN MAX({packagecount}) > SUM({shipmentpackage.trackingnumber}) THEN 1 ELSE 0 END)", "equalto", "1"]
the "max" at the beginning is giving it an error of:
Copy code
{
   type: "error.SuiteScriptError",
   name: "INVALID_SRCH_SUMMARY_TYP",
   message: "An nlobjSearchFilter contains an invalid summary type: formulanumeric: MAX.",
   stack: [
      "getRange(N/searchObject)",
      "getInputData(/SuiteScripts/HB_MRS_Ooze_Remove_Blank_Package_Lines.js:68)"
   ],
   cause: {
      type: "internal error",
      code: "INVALID_SRCH_SUMMARY_TYP",
      details: "An nlobjSearchFilter contains an invalid summary type: formulanumeric: MAX.",
      userEvent: null,
      stackTrace: [
         "getRange(N/searchObject)",
         "getInputData(/SuiteScripts/HB_MRS_Ooze_Remove_Blank_Package_Lines.js:68)"
      ],
      notifyOff: false
   },
   id: "",
   notifyOff: false,
   userFacing: false
}
b
you probably want to create the search first in the ui, then export it to script
n
@battk that's exactly what I did and this is the export results ^ but it doesn't work with the summary criteria
b
What are the filters and columns
n
var itemfulfillmentSearchObj = search.create({
type: "itemfulfillment", filters: [ ["type", "anyof", "ItemShip"], "AND", ["packagecount", "greaterthan", "1"], "AND", ["taxline", "is", "F"], "AND", ["cogs", "is", "F"], "AND", ["mainline", "is", "F"], "AND", ["trandate", "within", "thisfiscalyear"], "AND", ["internalidnumber", "equalto", "3737444"], "AND", ["shipping", "is", "T"], "AND", ["max(formulanumeric: CASE WHEN MAX({packagecount}) > SUM({shipmentpackage.trackingnumber}) THEN 1 ELSE 0 END)", "equalto", "1"] ], columns: [ search.createColumn({ name: "internalid", label: "Internal ID" }), search.createColumn({ name: "trandate", sort: search.Sort.DESC, label: "Date" }), search.createColumn({ name: "postingperiod", label: "Period" }), search.createColumn({ name: "type", label: "Type" }), search.createColumn({ name: "tranid", label: "Document Number" }) ] });
b
you should double check that the search does what you want it to do
n
it does
b
summary columns and summary filters are linked
n
so I should see if by grouping my results the search will run?
b
you will need to group your search columns to make your summary search filters do anything
that said, i dont think your summary filter does anything useful
n
haha, perhaps - i will take a look
b
in particular,
SUM({shipmentpackage.trackingnumber})
is probably nonsense
its why i asked if your search does what you want it to do
n
I am trying to build a search where if there are blank lines (aka package lines with no tracking number) then I need the fulfillment as a result
since I need to remove lines without package tracking numbers
b
what wrong with tracking number is empty
n
can't remember - I tried that but it wasn't giving what I wanted but I'll check the search out again. Basically package count > 1 AND at least 1 tracking number is empty is what i'm looking for
b
your tracking number isnt a number, you cant sum it
use a count
101 Views