This topic contains 8 replies, has 2 voices, and was last updated by NetV SuiteY 4 years, 10 months ago.
-
AuthorPosts
-
March 21, 2017 at 4:36 pm #1020
darrenhillconsultingHas anyone successfully disabled a field in a client script with SS2.0? I’ve hit a dead end and am desperate.
This is a cached copy. Click here to see the original post. -
March 21, 2017 at 9:30 pm #1021
michoelYou need to set the isDisabled property on the field.
Code:
require([‘N/currentRecord’], function(currentRecord) {
var record = currentRecord.get();
var field = record.getField({ fieldId: ‘entity’ });
field.isDisabled = true;
}); -
March 22, 2017 at 6:09 am #1022
JacksonPWhat Michoel said, you can save one extra line with this.
Code:
eventRecord.getField({
fieldId: ‘custevent12’
}).isDisabled = true; -
March 22, 2017 at 8:02 am #1023
darrenhillconsultingOk, so here’s a bit of a beef (rant) …
The script context gives me the currentRecord, so do I really need to import the currentRecord module?
Example:
Code:
context.currentRecord.getField({fieldId: ‘entity’}).isDisabled = true;
Works exactly the same asCode:
var record = currentRecord.get();
var field = record.getField({ fieldId: ‘entity’ });
field.isDisabled = true;
(Rant over)So, it appears my REAL issue is that the getSublistField function fails!! (arg)
Example:
Code:
var currIndex = context.currentRecord.getCurrentSublistIndex({ sublistId: ‘assignee’ }); // This works fine
var itemField = context.currentRecord.getSublistField({sublistId: ‘assignee’, fieldId: ‘serviceitem’, line: currIndex}); // ERROR!!!!
itemField.isDisabled = true;Code:
var record = currentRecord.get();
var currIndex = record.getCurrentSublistIndex({ sublistId: ‘assignee’ }); // This works fine
var itemField = record.getSublistField({sublistId: ‘assignee’, fieldId: ‘serviceitem’, line: currIndex}); // ERROR!!!!
itemField.isDisabled = true; -
March 22, 2017 at 4:04 pm #1024
michoelOriginally posted by darrenhillconsulting
View Post
The script context gives me the currentRecord, so do I really need to import the currentRecord module?
You don’t, as long as you are in an “entry point client script”, currentRecord is automatically imported and available in the context.
https://system.netsuite.com/app/help…625600928.html
(I just included it in the example to make it more self contained – you can copy and paste that in the Browser Console to test it for example).
-
March 22, 2017 at 5:22 pm #1025
markjasonfloresYeah, as michoel noted, in an entry point client script, you do not have use the get method to retrieve the current record. In these scripts, a currentRecord object is automatically created when the script is loaded. It is part of the context object that passed to each of the client script typeโs entry points. All you need is to get a variable to represent the current record
var currentRec = context.currentRecord();
var itemField = currentRec.getSublistField({sublistId: ‘assignee’, fieldId: ‘serviceitem’, line: 1});
itemField.isDisabled = true;
This should work, though if it still errors out, there might be an issue either with the sublist assignee or getting a select field using getSublistField, I suggest filing a support case in these cases.
-
March 28, 2017 at 6:41 pm #1026
darrenhillconsultingSo frustrating. Anyway I could ‘wrap’ the nlapiDisableLineItemField(‘assignee’, ‘serviceitem’, true); and call it from SS2.0? I’d hate to undo the SS2.0 migration for a single line of code.
-
March 29, 2017 at 8:25 am #1027
darrenhillconsultingSee my latest post … Client Script hack that could save your life!
-
January 22, 2020 at 7:49 pm #26128
User below one:
a mixture of SS1.0 & SS2.0
var objRec_Curr = scriptContext.currentRecord;
var TransferType = objRec_Curr.getCurrentSublistValue({sublistId:’xxxxxxxxxx’, fieldId : ‘xxxxxxxxxxxx’});
if(TransferType == ‘ABC’)
eval(“nlapiDisableLineItemField(‘custpage_sublist_out’, ‘custpage_out_transfer_location’, true)”);
else
eval(“nlapiDisableLineItemField(‘custpage_sublist_out’, ‘custpage_out_transfer_location’, false)”);
- This reply was modified 4 years, 10 months ago by NetV SuiteY.
-
AuthorPosts
You must be logged in to reply to this topic.