This topic contains 2 replies, has 0 voices, and was last updated by jmessersmith 8 years ago.

  • Author
    Posts
  • #6096

    jmessersmith

    Has anyone been able to update an inventory count status? I am simply trying to change the status to “Started” with the code below but no luck. It can be changed from any other status to “Open”.

    I ultimately want to mark it as approved. Is there an undocumented transformation for inventory counts to get this done?

    Code:
    function search(){

    var record = nlapiLoadRecord(“inventorycount”,19034645);
    record.setFieldValue(“statuskey”, “B”);
    record.setFieldValue(“status”, “Started”);
    record.setFieldValue(“statusRef”, “started”);
    var recId = nlapiSubmitRecord(record, false);

    }
    This is a cached copy. Click here to see the original post.

  • #6097

    johnsongilpp

    Hi, did you have any luck on this? I’m having the same issues as you. I reached out to NetSuite and will let you know if they come back with an answer.

  • #6098

    jmessersmith

    Nope, I put in a ticket and they marked it was an enhancement. We ended up just creating a custom record that has User Events to generate inventory adjustments. We basically recreated the Inventory Count with a custom record. So far it works well.

    UE code is below.

    Code:
    var nextinvtcountdate = new Date();
    nextinvtcountdate.setDate(nextinvtcountdate.getDate() + 720);
    var today = new Date();

    function createInvAdj(type){

    if (type == ‘edit’ && nlapiGetFieldText(“custrecord_cycle_count_status”)==”Completed”) {
    nlapiLogExecution(‘DEBUG’, “createInvAdj”, “createInvAdj”);
    var InvAdjRecord = nlapiCreateRecord(‘inventoryadjustment’);
    //InvAdjRecord.setFieldValue(‘memo’,datain.memo);
    InvAdjRecord.setFieldValue(‘account’,1028);
    var adjustqtyby = nlapiGetFieldValue(“custrecord_cycle_count_inven_counted”) – nlapiGetFieldValue(“custrecord_cycle_count_inven_snapshot”);
    InvAdjRecord.selectNewLineItem(‘inventory’);
    InvAdjRecord.setCurrentLineItemValue(‘inventory’,’item’,nlapiGetFieldValue(“custrecord_cycle_count_item”));
    InvAdjRecord.setCurrentLineItemValue(‘inventory’,’adjustqtyby’, adjustqtyby);
    InvAdjRecord.setCurrentLineItemValue(‘inventory’,’location’,nlapiGetFieldValue(“custrecord_cycle_count_location”));
    InvAdjRecord.commitLineItem(‘inventory’);

    var id = nlapiSubmitRecord(InvAdjRecord, false);
    nlapiLogExecution(‘DEBUG’, “InvAdjRecord.id”, id);

    nlapiSetFieldValue(“custrecord_cycle_count_related_adjustmen”,id);
    nlapiSetFieldValue(“custrecord_cycle_count_status”,6); //Adjusted and Completed
    setItemLastCountDate(nlapiGetFieldValue(“custrecord_cycle_count_item”), nlapiGetFieldValue(“custrecord_cycle_count_location”))

    }
    }

    function setItemLastCountDate(item, loc){
    //Update the item record to have the proper “Last Count Date” for a specific location
    nlapiLogExecution(‘DEBUG’, “setItemLastCountDate”, item + “:” + loc);
    var itemRecord = nlapiLoadRecord(‘inventoryitem’, item);
    var locCount = itemRecord.getLineItemCount(‘locations’);
    nlapiLogExecution(‘DEBUG’, “count”, locCount);

    for (var ii=1; ii<=locCount; ii++ ) {
    if (itemRecord.getLineItemValue('locations', 'location', ii)==loc){
    nlapiLogExecution('DEBUG', itemRecord.getLineItemValue('locations', 'location', ii), loc);
    itemRecord.setLineItemValue('locations', 'lastinvtcountdate', ii, nlapiDateToString(today, 'date'));
    itemRecord.setLineItemValue('locations', 'nextinvtcountdate', ii, nlapiDateToString(nextinvtcountdate, 'date'));
    itemRecord.setLineItemValue('locations', 'invtcountinterval', ii, 720); //720 days
    itemRecord.setLineItemValue('locations', 'invtclassification', ii, 1); //A
    }
    }
    var lineRecord = nlapiSubmitRecord(itemRecord, false);
    }

You must be logged in to reply to this topic.