Skip to main content The Trailblazer Community will be unavailable from 2/1/2025 to 2/2/2025. Please plan your activities accordingly.
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;

     }

     }   

   }
4 answers
  1. Aug 24, 2016, 11:26 AM
    Hi,

    Shouldnt we create Account,Opportunity instances and then create the custom object instance ?

    Also "OwnerId=Userinfo.getUserId());" how does this work?

    Thanks

     
Loading
0/9000