You need to sign in to do that
Don't have an account?
atharva Vispute 3
Help me to solve this problem
Hi,
Create an apex trigger on Resource to make sure that It does not exceeds Project assignment limit as per Defined on Project types.
· If Project.Type == Hot than max 4 Resources Allowed to be created under that project
· If Project.Type == Warm than max 2 Resources Allowed to be created under that project
· If Project.Type == Cold than max 1 Resource is Allowed to be created under that project
Example: Consider there is project named “TUV” with Type as “Warm” than system should only allow max 2 resources to be relate to TUV Project, if User tries to related more than 2 resources than System should Throw error that “Project Assignment Limit Reached” .
Plzz help me to find this solution in trigger.
Thanks!!
Create an apex trigger on Resource to make sure that It does not exceeds Project assignment limit as per Defined on Project types.
· If Project.Type == Hot than max 4 Resources Allowed to be created under that project
· If Project.Type == Warm than max 2 Resources Allowed to be created under that project
· If Project.Type == Cold than max 1 Resource is Allowed to be created under that project
Example: Consider there is project named “TUV” with Type as “Warm” than system should only allow max 2 resources to be relate to TUV Project, if User tries to related more than 2 resources than System should Throw error that “Project Assignment Limit Reached” .
Plzz help me to find this solution in trigger.
Thanks!!
Can you try the below apex trigger.
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,
All Answers
In the above scenerio Project is the parent object and Resource is child object. Can you confirm the API name of project lookup in Resource object.
Thanks,
Project_Name__c This is the API name in lookup object.
Thanks!!
Can you try the below apex trigger.
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,
No error in code but I am not getting any output.
Thanks!!
Are you trying to create 5th resource record on project with type__c field as 'Hot' ?
Thanks,
Yes I am creating 5th record and field type is also hot
Thanks!!
Did you check the debug logs in developer console after creating a new record?
Are you able to get the twi system.debug statements?
Thanks.
Yes, I am getting that statement.
Thanks!!
Are you getting three statemnst and values. Can you share the screenshot of it.
Thanks,
No I am not geeting that three statements.
Thanks!!
Can you share. the screenshot of the log here in screenshot.
Thanks,
Thanks!!
This is working on my org. Can you check the API names of the objects and also related list as well . This is working as expected in my org with the above trigger.
If you need we can connect and check the issue.
Thanks,
Now it's working.
Thanks!!
Can you confirm what excatly the issue is and how is it resolved.
Thanks,
I guess there is an issue in my org so run it in my friends org and ir works.
Thanks!!
Thanks for confirming.
Happy Learning!!
Thanks,
Yhank you very much for helping me.. If you don't mind can you provide me your contact detail, So i can reach you via mail or contact no also..
Thanks!!
I am happy to know this! I am a regular visitor of developer forums. Feel free to make a new post about where you are stuck and I’m here to help :)
Thanks,