You need to sign in to do that
Don't have an account?
Complicated Query/Trigger Help - A Challenge!!
Hi,
This seems quite complex to me, but I am sure one of you experts out there will see this as easy!!
I have a number of custom objects:
- Service_Agreement__c
- Training__c
- Employee_Training_Action__c (Joining Object - joining Employee__c and Training__c)
- Employees__c
- Operator_Skill_Level__c
- OSLSA_Join__c (Joining Object - joining Service_Agreements__c and Operator_Skill_Level__c)
- EmployeeOSL_A__c (Joining Object - joining Employees__c and Operator_Skill_Level__c)
Effectivly where I am at the moment is that when a value is checked on Service_Agreements__c a new Training__c record is created linked to the SA. Also, The Service_Agreement__c is linked to one or many Operator_Skill_Level__c records through the OSLSA_Join__C object.
Each Employee__c record is also linked to one or many Operator_Skill_Level__c records through the EmployeeOSL_A__c object.
What I need, is when the Training__c record is created, the relevent Operator Skill Level(s) are retrieved from the related SA and then all of the employees__c that belong to the OSL(s) are related back to the Training__c record.
I think I have covered everything off their, Im guessing this is just a complex SOQL query . but any help would be really apprecaited.
Thank you in advance.
Assuming the total number of Operator_Skill_Level__c objects is pretty small and almost static, you could use a relationship query on the service agreement to figure this out. I've hacked together some pseudocode to demonstrate. Obviously, this needs to be tweaked quite a bit to actually work.
And wham, you've got a list of OSLs for that particular service agreement, and only one extra SOQL query. I had to make some assumptions about object and field names, but I think you'll get the idea.