The function disableAllObjects() will disable all objects on a form. nuEnableAllObjects() will enable all objects.
Provide the optional argument excludeTypes (array) to exclude certain object types.
☛ Add the following JavaScript Code to your form’s Custom Code field. Or add it under Setup -> Header, if the functions are going to be used in several forms. (They are already included in nuBuilder v4.5)
Click to view the code!
function nuEnableDisableAllObjects(v, excludeTypes, excludeIds) {
if (typeof excludeTypes === 'undefined') {
let excludeTypes = [];
}
if (typeof excludeIds === 'undefined') {
let excludeIds = [];
}
var r = JSON.parse(JSON.stringify(nuSERVERRESPONSE));
for (var i = 0; i < r.objects.length; i++) {
let obj = r.objects[i];
if ($.inArray(obj.type, excludeTypes) == -1 && $.inArray(obj.id, excludeIds) == -1 ) {
nuEnable(obj.id, v);
}
}
}
function nuEnableAllObjects(excludeTypes, excludeIds) {
nuEnableDisableAllObjects(true, excludeTypes, excludeIds);
}
function nuDisableAllObjects(excludeTypes, excludeIds) {
nuEnableDisableAllObjects(false, excludeTypes, excludeIds);
}
nuDisableAllObjects();
nuEnableAllObjects();
nuDisableAllObjects(['html', 'display', 'word']);
nuDisableAllObjects([],['cus_name']);
if (nuFormType() == 'edit') {
var alc = nuAccessLevelCode();
if (!window.global_access || !alc == 'manager') {
nuDisableAllObjects();
}
}