Can I add and view related records using recursion

For instance I have a loosely defined hierarchy of people. A person records contains at least these properties: name, email, manager name, manager email.

I have a many to one relationship from this object to itself and that is used with a signal to relate people to their managers.

Q1. Can I use rules to create all the relationships between a single record and their decedents? (without knowing the depth of the search)

Q2. How would I create a list to show all the people at all levels below a manager?

Afternoon Craig,

What a fantastic question and the answer is a resounding yes.

To Answer Q1 :
What you would need to have is the employee id of a single line manager per employee in your user table pointing to a corresponding employee id for the manager. The next step would be to form a one to many relationship from the user object back to the user object labelling the one (parent / line manager) to many (child / report).

Next use a signal and a rule to form the relationship across this newly formed circular relationship based upon the matching of line manager id to employee id. This circular arrangement is a pre-requisite of my answer to Q2. The rule is 'Add Relationship by Matching’.

You would want a subset to exclude those who already have a relationship to a line manager for your signal, and you would want another rule to fire to form the relationship for new employees. You do not need to worry about the depth because you are relating every employee to their line manager not attempting to relate many line managers to their many employees.

To Answer Q2 :
Now that you have a circular relationship you can use our Tree Widget, starting at the child. The widget will then ask for the relationship to the parent. The widget should then display a tree of Line managers and Employees. If set as editable the widget will allow the relationships to be changed. Clicking can link you to the employee page.

Edit: @LewisGallagher has just brought to my attention that we also have a widget in AppShare that can display an Organisation Chart. Please let us know how you get on.

https://community.netcall.com/appshare/i/organisation-chart/

1 Like

Thanks @adam.mills and @LewisGallagher

Not quite, what I’m looking to do with this. This is great and I’ll find a use now that I know about these.

The feature I’m trying to deliver is for a manager(s) that have many sub teams below them.

Manager A
officer 1 reports to Manager A
Sub manager B reports to manager A
officer 3 reports to manager B
officer 4 reports to manager B
Sub manager C reports to manager A
officer 5 reports to manager C
officer 6 reports to manager C

I’d like to build a page where the Manager A can see at a glance some reporting metrics, e.g. number of assigned cases that each of those other people have.

Sorry Craig for that particular use case I would suggest a custom vue presenter.

Shouldn’t be that difficult to build a recursive lookup from the manager line and present the name alongside a case count.