Hello,---------TRIGGER----------trigger UpdateReportName on ActivityPlanningAndReport__c (before insert) { Map<Id,User> ownerMap; Set<Id> oppOwnerIds = new Set<Id>(); String nameOfOwner; for(ActivityPlanningAndReport__c p : trigger.new) { oppOwnerIds.add(p.OwnerId); } ownerMap = new Map<Id,User>([SELECT Id, Name FROM User WHERE Id IN :oppOwnerIds]); for(ActivityPlanningAndReport__c p : trigger.new) { nameOfOwner = ownerMap.get(p.OwnerId).Name; if(p.Name!=null) { p.Name = p.Country_txt__c+'_'+ p.Display_Engagement_Date__c+'_'+nameOfOwner; } } }
Hi,Shouldnt we create Account,Opportunity instances and then create the custom object instance ?Also "OwnerId=Userinfo.getUserId());" how does this work?Thanks