You need to sign in to do that
Don't have an account?
Sufal Kanungo
Employee count in the department object in the headcount field through the apex trigger??
I am new in salesforce. How can I get the employee count in the department object in the headcount field through the apex trigger??
Can you try the below trigger on Employee object.
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,
All Answers
Can you confirm how are Employee and Department objects related to each other. Which is Parent and which object is Child object.
Thanks,
The department is the parent object and Employee is the child object Basically, it is the master-detail relationship.
Can you try the below trigger on Employee object.
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,
This works for both Master Detail and Lookup relations. Can you confirm what exactly is not working here. Did you trigger got saved without any issue?
Thanks,
.
Did you try creating a new. Employee record under any of the Deparment ?
Thanks.
The above code should work with out any issue because it is working as expected in my org. Are you checking correct department record ( Department related to the Employee you edited) ?
Thanks,