Hello Community,
is there a script or tool in creatio that convert hierarchy of records like employees/department into an organization chart.
Like
2 comments
17:19 Oct 04, 2023
I can't give you a solution (you could try the Marketplace), however some C# I wrote recently to traverse the employee tree using the employee `ManagerId` which may be of use as a starting point (it returns a list of all staff subordinate to the starting employee):
using Terrasoft.Configuration;
using Terrasoft.Core;
using Terrasoft.Core.DB;
using System;
using System.Data;
using System.Collections.Generic;
namespace Terrasoft.Configuration.UsrEmployeeTree
{
public class EmployeeTree
{
private UserConnection UserConnection;
private Guid employeeId;
public EmployeeTree(UserConnection userConnection) {
UserConnection = userConnection;
}
public void TraverseTree(Guid employeeId, List<Guid> staff) {
staff.Add(employeeId);
var select = new Select(UserConnection)
.Column("Id")
.From("Employee")
.Where("ManagerId").IsEqual(Column.Parameter(employeeId))
as Select;
using (DBExecutor dbExecutor = UserConnection.EnsureDBConnection()) {
using (IDataReader dataReader = select.ExecuteReader(dbExecutor)) {
while (dataReader.Read()) {
TraverseTree(dataReader.GetGuid(dataReader.GetOrdinal("Id")), staff);
}
dataReader.Close();
}
dbExecutor.Close();
}
}
}
}
Show all comments