I have used "field.Disabled=true" for disabling the field.
In-fact, as per the Suite Script 2.0 API, documentation provides the definition provides like this:
If you are working with a sublist field, you can set this property to true or false, but
be aware that this action affects the entire sublist column, even though a sublist field is
associated with one line.
¦ For both body and sublist fields, you can use Field.isDisabled to determine whether
the field is disabled or enabled.
To overcome the above issue i have followed below steps:
1. Created a client script, under the "lineinit(context)" section, added below lines of Code:
function lineInit(context) {
var invoice = context.currentRecord;
var selectedLine = invoice.getCurrentSublistIndex({
sublistId: 'item'
});
var qty = invoice.getCurrentSublistValue({
sublistId: 'item',
fieldId : 'quantity',
});
if (qty > 1.0) {
invoice.getSublistField({
sublistId : 'item',
fieldId: 'description',
line:0
}).isDisabled = true;
}
else {
invoice.getSublistField({
sublistId : 'item',
fieldId: 'description',
line:0
}).isDisabled = false;
}
}
Here I have considered "line" number as "0", line is a mandatory option in the .getSublistField() method. The main use of lineinit is, the code is executed when an existing line is selected. Since the code is executed at line level, so everyline will hold line number as 0.
In the above line the Description field is disabled the the item quantity has crossed more than 1.
Note: this will work absolutely fine in SuiteScript1.0 without any line number. below is the method need to be used.
nlapiDisableLineItemField(type, fldnam, val)
Thanks
No comments:
Post a Comment