You need to sign in to do that
Don't have an account?
Oliver Freeman 9
Count Related Records on Case
Hi There!
I have a custom object (Contract Loan) which is related to the Case object, and I'd like to be able to count how many Contract Loan records there are related to each case.
I can't use a ROLLUP Summary, because we don't have (don't want) a Master-Detail Relationship field on the Contract Loan object to the case, so it'd need to be done by an APEX Trigger - I won't lie, I have no idea what I'm doing.
Can anyone give me a hand at starting this, please?
Thanks,
Oli
I have a custom object (Contract Loan) which is related to the Case object, and I'd like to be able to count how many Contract Loan records there are related to each case.
I can't use a ROLLUP Summary, because we don't have (don't want) a Master-Detail Relationship field on the Contract Loan object to the case, so it'd need to be done by an APEX Trigger - I won't lie, I have no idea what I'm doing.
Can anyone give me a hand at starting this, please?
Thanks,
Oli
Hi Oliver,
Below is code snippet which will help you definately :)
Please Mark as best answer, If it works otherwise let me know the issue :)
Thanks
Rajat Maheshwari
rajatzmaheshwari@gmail.com
All Answers
Hi Oliver,
Below is code snippet which will help you definately :)
Please Mark as best answer, If it works otherwise let me know the issue :)
Thanks
Rajat Maheshwari
rajatzmaheshwari@gmail.com
Here in code,
1. Contract_Loan__c is child object
2. Case is parent object
3. Case__c is lookupField on Contract_Loan__c
4. number_of_Contract_Loans is number field in Case which will hold the count of related record
Thanks
Hi Oliver,
Does my code helps to fix your issue? please let me know
Thanks
Hey,
Thanks for your help on this, I've only just got around to implementing this.
Is there any way that I can make this trigger depend on the Status__c field value on the contract loan object? For example, if status set to closed or rejected, remove from count.
Thanks,
Oli