This topic contains 4 replies, has 0 voices, and was last updated by egrubaugh 8 years, 2 months ago.
-
AuthorPosts
-
August 23, 2016 at 10:39 am #1849
JacksonPI’m writing a client script and I’m trying to figure out how to change a field’s display type. Basically I’m making fields dependent on each other. Say I have 3 fields…
If Field 1 is empty, field 2 and 3 are disabled to edit.
If Field 1 contains something, I want to enabled field 2, but if Field 2 is empty, Field 3 Is still disabled…
I figured it would be in the ‘N/record’ module, but I can’t find anything that will let me changed the Field’s Display type.
Thanks for the help!
This is a cached copy. Click here to see the original post. -
August 23, 2016 at 10:44 am #1850
MChammaTXOff the top I’m not sure. If I remember you could only disable fields in beforeLoad in SS 1.0, although my memory is fuzzy. Not sure if this is now possible in 2.0.
My workaround faced with 1.0 was to use workflows as this was possible client side.
Maybe others can provide better insight?
JacksonP replied on 08/23/2016, 11:48 AM: I did find under fieldChanged in client scripts it specifically says ‘Disable or enable fields based on user input’
-
August 23, 2016 at 12:04 pm #1851
khultquistNope, you cannot change the Field Display Type in a client script, only in a user event script.
Consider using a Validate Field function for the dependent fields. You can build the same logic but it behaves a little differently in the UI.
JacksonP replied on 08/23/2016, 12:48 PM: Alright, thanks for the help.
-
August 23, 2016 at 5:47 pm #1852
michoelOriginally posted by khultquist
View Post
Nope, you cannot change the Field Display Type in a client script, only in a user event script..
You definitely can do this, here is an example of making the ‘comments’ field enabled only if ‘companyname’ is not empty
Code:
/**
* @NApiVersion 2.x
* @NScriptType ClientScript
*/
define([], function() {return {
fieldChanged: function(context) {
if(context.fieldId === ‘companyname’) {
var record = context.currentRecord;
var isDisabled = record.getValue({ fieldId: ‘companyname’ }) ? false : true;
record.getField({ fieldId: ‘comments’ }).isDisabled = isDisabled;
}
}}
});
khultquist replied on 08/23/2016, 07:55 PM: Very cool, it’s time for me to learn SuiteScript 2.0
-
August 29, 2016 at 9:14 am #1853
egrubaughYou should be able to disable/enable fields at will in a Client Script using the supported 1.0 `nlapiDisableField` method. It just takes the field ID and a Boolean as arguments; send in `true` to disable the field and `false` to enable it.
Code:
nlapiDisableField(‘custfieldid’, true);
We use this several places in our SuiteApp with no issues. -
AuthorPosts
You must be logged in to reply to this topic.