Good morning everyone - I have a bit of a stumper ...
# suitescript
a
Good morning everyone - I have a bit of a stumper here. I am trying to update item fulfillment records with a scheduled script. Specifically, I am updating tracking information. The challenge with this is the "package" line type is not always just called "package". In some cases, it is "packageups" or "packagefedex" or just plain "package". Now, I have a function written that works perfectly in the console, but in the schedule script it bombs out with an error message stating that the lineitems are undefined. I am essentially trying this: var tranLines = ifRec.lineitems; var ups = tranLines.hasOwnProperty('packageups'); var fedex = tranLines.hasOwnProperty('packagefedex'); and then I go into some if logic on how to update each of those specific line types. The error message is specifically - cannot call method "hasOwnProperty" of undefined. thanks in advance for any thoughts or assistance!!
j
When testing in the console and then doing the scheduled you are targeting just the one IF record correct? It looks like you are hitting an item fulfillment were there isn't a transLines object.
a
I'm just copying and pasting the entirety of the script into the console and running it, it runs the saved search and then fires off through them until it runs out of usage. I thought something similar, but that doesn't seem to be the case.
And at the point where it fails, I know its already ran the search and loaded the record, it just seems like the lineitems aren't there, like you said.
j
I'd add some logs around the steps and an if(transLines) condition around the hasOwnProperty calls to get an idea of where and when it's failing and take a look at the records.. either you'll find your problem or you won't find anything wrong in which case you and hesitantly leave the if statement... though I'd stay curious as to why lineitems might not be found if there should be some.
a
Yea, I'll give that shot and see if I can come up with something. Its so strange. I just wanted to make sure there wasn't something wrong with using hasOwnProperty in the server side context or something with scheduled scripts that it wouldn't work. Thanks!