Skip to content

Latest commit

 

History

History

edit_screen_disable_all_objects

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Edit Screen: Disable/Enable all Objects

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)

How to add Custom Code

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);

}

✪ Example 1: Disable all objects

nuDisableAllObjects();

✪ Example 2: Enable all objects

nuEnableAllObjects();

✪ Example 3: Disable all objects but exclude some types.

nuDisableAllObjects(['html', 'display', 'word']);

✪ Example 4: Disable all objects but exclude the object with id "cus_name"

nuDisableAllObjects([],['cus_name']);

✪ Example 5: Disable all objects but not for globeadmin and the Access Level "manager"

if (nuFormType() == 'edit') {
    var alc = nuAccessLevelCode();
    if (!window.global_access || !alc == 'manager') {
        nuDisableAllObjects();
    }
}