I am posting to chatter using an apex trigger whenever the opportunity stage changes to a certain value. The problem I'm having is that I'm trying to concatenate the opportunity owner name with some text but I can only get the ID of the owner. Is there a way I can simply get the opportunity owner name and concatenate it with the text? The query is returning the list i want but displays the key value pair, and i just want to get the firstname and lastname.
List<User> name= new List<User>();
name = [SELECT FirstName FROM User WHERE Id=:o.Opp_Owner_Name__c];
post.Body = 'Test' + name.get(0);
Best Answer
Please use the following query as Priyanka Rightly said that we cannot get those directly in Trigger.New .