Update Script for a value column in Person Table

I wanna add a modification to a script used for calculating the CCC_Direction value in the Person table. CCC_Direction corresponds to the Direction to which the person is attached calculated based on DepartmentName column in the Department table as shown in the atatched pdf.

Currently, the script retrieves only the department name from the Department table to populate the CCC_Direction field. However, I would like to add two additional functionalities to enhance this process.

Recalculation of CCC_Direction value on manager modification:
- Whenever a value is directly changed in the manager for the CCC_Direction field, I would like the script to recalculate the corresponding department value and update it accordingly.

- When an organization name is modified in the Department table, I would like the script to recalculate the CCC_Direction value for all individuals associated with that organization.


I have reviewed the PDF document in the drive link summarizing the Person and Department tables, as well as the existing script for retrieving these fields. However, I was unable to successfully implement the above functionalities.

https://drive.google.com/file/d/1ABRaALcQVHy2vE3wQ8e068mQnsAOj3aU/view?usp=sharing