This topic contains 9 replies, has 0 voices, and was last updated by MarkZSSI 8 years, 3 months ago.

  • Author
    Posts
  • #6241

    MarkZSSI

    I’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.

  • #6242

    khultquist

    You cannot set quantityonhand or quantitycommitted, these are read only fields on Item records. To adjust quantities, use Transaction records.

  • #6243

    MarkZSSI

    Originally 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.

  • #6244

    MarkZSSI

    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 the inventoryitem level for the warehouse?

  • #6245

    egrubaugh

    Unrelated to the question itself, what is the intent of the

    Code:
    || [];
    portion of

    Code:
    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.

  • #6246

    david.smith

    I 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.

  • #6247

    egrubaugh

    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.

  • #6248

    MarkZSSI

    Originally 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?

  • #6249

    david.smith

    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.

  • #6250

    MarkZSSI

    Originally 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!

You must be logged in to reply to this topic.