How do I populate/calculate the headcount field for Departments (cmn_department table) based on the Users department?

Paul Wilson
Giga Contributor

Hi there, 

how can I get the Head_count field in the Departments table to be calculated based on the total of users with that department selected. This needs to be updated perhaps once every 24 hours. 

Script examples would be very much appreciated 🙂

regards

Paul

1 ACCEPTED SOLUTION

Paul Wilson
Giga Contributor

Brilliant! thank you Aidan 🙂

View solution in original post

8 REPLIES 8

Community Alums
Not applicable

I can't imagine why not. You could write an on Submit business rule that updates the headcount everything a department record is updated and store the headcount at that point, that way its no longer a calculated value.

Paul Wilson
Giga Contributor

Brilliant! thank you Aidan 🙂

Community Alums
Not applicable

Not sure why you marked your reply as the correct answer instead of my solution haha, but glad I could help.

Hi @Community Alums - sorry for bringing up an old post. I implemented your solution and it's calculating correctly. 

 

The only issue I'm seeing is when trying to sort the Department list view by Head count - for some reason it won't order them from lowest to highest or vice versa. Did you encounter this problem?