How to disable a configuration key from X++

Please be aware that by running this code, you'll loose data in any table associated with the configuration key.

 ConfigurationKeySet configurationKeySet = new ConfigurationKeySet();

;
configurationKeySet.loadSystemSetup();
configurationKeySet.enabled(configurationKeyNum(MyConfigKey));
SysDictConfigurationKey::save(configurationKeySet.pack());
SysSecurity::reload(true, false);

This posting is provided "AS IS" with no warranties, and confers no rights.