I was wondering if there is a way to access the User information page to obtain the Country and Title from that page, for people that are invited to an Event.
So, I created an Event and invited a number of USER/s. My intention is to access the USER's info pages of those that are part of the "Invite Other" section.
Is this something possible using a formula function?
Thanks on advanced!
Hello guy,
I have a number formula, (total time) to obtain StartDate and EndDate duration in hours for every single event. Using the output of that formula I make some calculations.
First I access the event's owner user Country field. I do this to assign him a currency with something like this:
CASE($User.Country, "AUS", "Australian dollar", "US", "United States dollar", "No country assigned to user")
We have an hourly rate for some users and those rates are assign using this type of formulas, field name Hourly Rate :
IF(($User.Country = "CA" ),00.00, IF(($User.Country = "AUS" ),00.00, null))
All this is the output of a field call Activity Total Amount. A simple operation "Total Time * Hourly Rate"
So the request now is to add to the Total Amount formula field the rates for all users that are invited to an event.
So if an event takes one hour I need that the Activity Total Amount reflects amounts from the user that are invited together with the acctivity.owner.
Does this explains better what I'm looking for?
Attribution to: Carlos Naranjo
Possible Suggestion/Solution #1
Thanks guys,
I have solved now. I need to write a trigger to accomplish what I want. In case anyone needs to test this for future code here is a anonymous block of code that you can use for testing from your IDE or from a Developer Console:
//The whoRelations list contains users that accepted an invitation for an event
List<EventRelation> whoRelations = [SELECT Id, Relation.Name, Status FROM EventRelation WHERE
EventId = 'YourEventID' AND Status = 'Accepted'];
// If there is at least one user you can see his/her
//name and Id by using Relation.Name and Relation.Id
System.debug(whoRelations[0].Relation.Name);
System.debug(whoRelations[0].Relation.Id);
//I created an Id list to pass the ids in whoRelations list to the new userId list.
List<Id> userId = new List<Id>();
//We pass all ids to our userId list now
for(Integer i=0; i<whoRelations.size(); i++){
userId.add(whoRelations[i].Relationid);
}
//Now we just use a SOQL on the User object for users on our userId list.
//From here we can now access all user's details fields.
System.debug(userId.size());
List<User> finalUsers = [SELECT Id, Name, Title, Country FROM USER WHERE Id IN :userId];
//In my test I had 2 users in my finalUsers list, to see the results I used this.
if(!finalUsers.IsEmpty()){
System.debug(finalUsers[0].Id);
System.debug(finalUsers[0].Country);
System.debug(finalUsers[1].Id);
System.debug(finalUsers[1].Country);
}
By using this I can now start building a trigger that will take the rest of my logic into the Event's page layout, allowing me to use data that are part on the User object.
Attribution to: Carlos Naranjo
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/34743