This topic contains 8 replies, has 2 voices, and was last updated by NetV SuiteY 4 years, 2 months ago.
-
AuthorPosts
-
darrenhillconsulting- Contributions: 0
- Level 1
- ☆
Has 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. -
michoel- Contributions: 0
- Level 1
- ☆
You 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;
}); -
JacksonP- Contributions: 0
- Level 1
- ☆
What Michoel said, you can save one extra line with this.
Code:
eventRecord.getField({
fieldId: ‘custevent12’
}).isDisabled = true; -
darrenhillconsulting- Contributions: 0
- Level 1
- ☆
Ok, 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; -
michoel- Contributions: 0
- Level 1
- ☆
Originally 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).
-
markjasonflores- Contributions: 0
- Level 1
- ☆
Yeah, 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.
-
darrenhillconsulting- Contributions: 0
- Level 1
- ☆
So 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.
-
darrenhillconsulting- Contributions: 0
- Level 1
- ☆
See my latest post … Client Script hack that could save your life!
-
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, 2 months ago by NetV SuiteY.
-
AuthorPosts
You must be logged in to reply to this topic.