0

I'm new to NetSuite. I need the checkbox "Landed Cost Per Line" on Item Receipt form to remain unchecked. I did try 2 ClientScript but it is not working.

When you click on "Receive" button on the Purchase order, it goes to the Item Receipt form and as the page loads, the checkbox is auto-checked. The checkbox is found under the "Item&Expenses" subtab.

I tried doing it via workflows but the field is not available/does not show there. So I tried via scripts.

[1.] The first try it unchecks it but then throws an error message "*TypeError Cannot read properties of undefined (reading 'setValue') suitescript*" and restrict you from navigating through subtabs.
/**
*@NApiVersion 2.x
*@NScriptType ClientScript
*/

define(['N/error', 'N/record'], function(error, record){
  function pageInit(context){
    if (context.mode == 'create' || context.mode == 'edit')
      var currentRec = context.currentRecord;
      currentRec.setValue({
        fieldId: 'landedcostperline',
        value: 'F'
      });
    }

  return{
    pageInit : pageInit
  };
});
[2.] With the second trial, nothing happened i.e the checkbox gets auto-check as the page loads.
/**
*@NApiVersion 2.x
*@NScriptType ClientScript
*/
define(['N/error', 'N/record'], 
    function(error, record){
        function pageInit(context){
            if (context.mode == 'create' || context.mode == 'edit'){
                var currentRec = context.currentRecord;
                currentRec.submitFields({
                    type: record.Type.ITEM_RECEIPT,
                    values: {
                        landedcostperline: 'F'
                    },
                    options: {
                        enableSourcing: false,
                        ignoreMandatoryFields : true
                    }
                });
            }
        }

        return{
          pageInit : pageInit
        };
    }
);

Where did I go wrong?

Mr. Stash
  • 2,940
  • 3
  • 10
  • 24
Zarah
  • 1
  • 1

1 Answers1

0

Forget about the scripts. Actually, it's a setting in Setup > Accounting > Accounting Preferences > Order Management. Just uncheck it there.

Zarah
  • 1
  • 1