learn suitescript
learn suitescript

Reputation: 1

Is there a way to disable a transaction column via Scripting with Netsuite 2.0?

I am required to write some code that disables a transaction column e.g. 'quantity' on a sublist e.g. 'item' on say a purchase order.

I seem to have reached a block as my code is not working.

See my code below:

/**
 * @NApiVersion 2.0
 * @NScriptType ClientScript
 * @NModuleScope SameAccount
 */
define(['N/record'],
/**
 * @param {record} record
 */
function(record) {
     function sublistChanged(scriptContext) {
        var currentForm = scriptContext.currentRecord;

        var getSublist = currentForm.getSublist({
            sublistId: 'item'
            fieldId: 'quantity'
                });
       getSublist.isDisabled = true;
        }

    return {     
        sublistChanged: sublistChanged,

    };

});

Upvotes: 0

Views: 2856

Answers (2)

erictgrubaugh
erictgrubaugh

Reputation: 8847

You do not use the isDisabled property to change field display. The proper way to modify field display types in NetSuite is to retrieve a reference to the Field object, then call its updateDisplayType() method. See the Help page titled Field.updateDisplayType(options) for details on this method.

To retrieve a reference to a sublist column, you:

  1. Retrieve a reference to the Sublist from the Form or Record
  2. Retrieve a reference to the Field from the Sublist
  3. Invoke updateDisplayType() on the Field

Will end up looking something like:

var sublist = context.newRecord.getSublist(...);
var column = sublist.getField(...);
column.updateDisplayType(...);

Upvotes: 1

Avi
Avi

Reputation: 2069

AFAIK, you cannot disable a sublist field in client script(As per NetSuite, isDisabled is read-only). You can only update sublist-field display type for sublist which were created using N/ui module.

Upvotes: 0

Related Questions