Skip to main content
Version: 52.0.0

Дія 'Видалення'

Special handler instance_canDelete allows to disable or hide 'delete' buttons on forms (table and user dictionary attributes). It's enables to control ability to delete entry from the script module.

instance_canDelete function can return either boolean value (enable or disable 'delete' button) or object with params

  • canDelete (boolean) - enable or disable 'delete button'
  • hideButton (boolean) - hide delete button from toolbar
  • reason (string) - tooltip for disabled button with reason to not delete this entry

Basic usage:

module.exports = {
instance_canDelete(event) {
// do not delete entry if attribute value exceeds the threshold
if (event.documentItem.getAttribute('someNumberAttr') > 200) {
return {canDelete: false, hideButton: false, reason: 'Value too much to delete!'}
}

// do not delete entry if text attribute value includes some keyword
// and use this value as reason to not delete entry
if (event.documentItem.getAttribute('someTextAttr') && event.documentItem.getAttribute('someTextAttr').indexOf('do not delete') > -1) {
return {canDelete: false, hideButton: false, reason: event.documentItem.getAttribute('someTextAttr')}
}

return true
}
}