I'm working on this trigger:
trigger ActivityCostInvitees on Event (after update){
List<EventRelation> whoRelations = [SELECT Id, Relation.Name, Status
FROM EventRelation
WHERE Event.Status_Event__c ='Completed'
AND EventId IN: Trigger.old];
List<Id> userId = new List<Id>();
if(Trigger.isAfter){
if(Trigger.isUpdate){
for(Integer i=0; i<whoRelations.size(); i++) {
if(!whoRelations.IsEmpty()){
userId.add(whoRelations[i].Relationid);
}else {
System.assert(false);
}
}
List<User> finalUsers = [SELECT Id, Name, Title, Country
FROM User
WHERE Id IN : userId];
}
}
}
Now, let's say that the 'finalUsers' contains two users. These users have different titles and are from different countries. I want to first know the Country of each of the users and the Title of each user. Based on that I will do some further calculations. Anyone?Thanks in advanced!
14-05-2014
Thank you for your replies. I think that maybe I was not clear enough on my question. Apologies :( ... I will try to put it on a different way.
I have make some modifications. I added the Rate__c amount field on the User detail page. The field Rate__c is just a formula that will assign a correct amount to the user by looking the Country and the Title. So that is great because I can save some code in my trigger. Now, the question is how do I sum the amount for each of the users inside the finalUsers list?
If I have 3 users in the finalUsers list how can I access each Rate__c for each user and sum the to get a total rate amount?
Any ideas?