Delete hierarchy
Deletes or hides a reporting structure. This example changes data: run it on a test company, after Save hierarchy.
hierarchies()->delete($code)deletes it. Delete is in the WSDL of the hierarchies service, not in its documentation.hierarchies()->hide($code)hides it (--hide).
An unknown code gives a HierarchyNotFoundException.
$twinfield = Example::twinfield();
// The reporting structure of the save-hierarchy example; `--hide` hides it instead.$code = $argv[1] ?? 'SDK_EXAMPLE';$hide = in_array('--hide', $argv ?? [], true);
try { if ($hide) { $twinfield->hierarchies()->hide($code); } else { $twinfield->hierarchies()->delete($code); }} catch (HierarchyNotFoundException $exception) { echo 'Not found: ', $exception->reason, PHP_EOL;
exit(1);}
echo $hide ? 'Hidden: ' : 'Deleted: ', $code, PHP_EOL;php examples/hierarchies/delete-hierarchy/example.phpphp examples/hierarchies/delete-hierarchy/example.php SDK_EXAMPLE --hideAdd TWINFIELD_DEBUG=1 to see the SOAP requests and responses.
Source
Section titled “Source”View examples/hierarchies/delete-hierarchy/example.php on GitHub.
Twinfield and Wolters Kluwer are trademarks of Wolters Kluwer. Their names and logos are used only to refer to their products.