This topic contains 9 replies, has 0 voices, and was last updated by MarkZSSI 8 years, 3 months ago.
-
AuthorPosts
-
August 11, 2016 at 9:24 am #6241
MarkZSSII’m trying to set the line item values for quantityonhand and quantitycommitted to the var that I have in place below in the code. It’s not working. I shouldn’t have to call it locationquanityonhand or locationquantitycommitted because I set the warehouse field value (row) first, correct?
Can someone tell me why this code doesn’t work?
Code:
var record = nlapiLoadRecord(‘inventoryitem’, itemId) || [];record.setFieldValue(‘location’, fen);
record.setLineItemValue(‘inventoryitem’, ‘item’, 1, itemId);
record.setLineItemValue(‘inventoryitem’, ‘quantityonhand’, 1, adjusted);
record.setLineItemValue(‘inventoryitem’, ‘quantitycommitted’, 1, adjusted);
var recordid = nlapiSubmitRecord(record, true);
This is a cached copy. Click here to see the original post. -
August 11, 2016 at 9:58 am #6242
khultquistYou cannot set quantityonhand or quantitycommitted, these are read only fields on Item records. To adjust quantities, use Transaction records.
-
August 11, 2016 at 10:06 am #6243
MarkZSSIOriginally posted by khultquist
View Post
You cannot set quantityonhand or quantitycommitted, these are read only fields on Item records. To adjust quantities, use Transaction records.
Ahhhh…. That makes sense! Thanks for the quick response.
-
August 11, 2016 at 11:01 am #6244
MarkZSSIFollow up question.
The transaction is an item receipt. I’m trying to set it via that, and have tried setting onhand and quantity. Neither of them do a thing. Ideas on how to set it on the inventoryitem level for the warehouse?
-
August 11, 2016 at 11:27 am #6245
egrubaughUnrelated to the question itself, what is the intent of the
Code:
|| [];
portion ofCode:
var record = nlapiLoadRecord(…) || [];
?If `nlapiLoadRecord` returns `null` for some reason, this will make `record` an empty array, but then all subsequent calls to `record.set*` will throw errors because those methods don’t exist in the Array prototype chain.
-
August 11, 2016 at 11:47 am #6246
david.smithI use the || [] all the time on my searches but never on a load record. All this is saying is that if it is null set the var to an empty array.
-
August 11, 2016 at 12:04 pm #6247
egrubaughCorrect; I use it as well for my search results because those are actually Arrays. I was looking for clarification on *why* it is being used in this situation, where an nlobjRecord is expected. Defaulting to an Array will only cause errors to be thrown for undefined methods.
-
August 11, 2016 at 12:11 pm #6248
MarkZSSIOriginally posted by egrubaugh
View Post
Correct; I use it as well for my search results because those are actually Arrays. I was looking for clarification on *why* it is being used in this situation, where an nlobjRecord is expected. Defaulting to an Array will only cause errors to be thrown for undefined methods.
Mistype! Thanks for questioning that. Now back to the question at hand.
Follow up question.
The transaction is an item receipt. I’m trying to set it via that, and have tried setting onhand and quantity. Neither of them do a thing.
Ideas on how to set it on theinventoryitem level for the warehouse?
-
August 11, 2016 at 12:17 pm #6249
david.smithYou can’t set that on an item receipt. I’m not sure if I follow what you’re asking exactly but you have to create an inventory adjustment nlapiCreateRecord(‘inventoryadjustment’, {recordmode:’dynamic’}); to adjust the onhand etc.
-
August 11, 2016 at 12:41 pm #6250
MarkZSSIOriginally posted by david.smith
View Post
You can’t set that on an item receipt. I’m not sure if I follow what you’re asking exactly but you have to create an inventory adjustment nlapiCreateRecord(‘inventoryadjustment’, {recordmode:’dynamic’}); to adjust the onhand etc.
Ok, that makes sense. Thanks!
-
AuthorPosts
You must be logged in to reply to this topic.