Skip to main content The Trailblazer Community will be unavailable from 2/1/2025 to 2/2/2025. Please plan your activities accordingly.
Hello, 

i hope you can help me.

I have a trigger on a the Event Object , that creates a Visit Report (Customized Object) after generating a Event. 

At the moment the trigger generate a visit report but i want to write back the id of the generated visit report into the event. 

can i handle this in only one trigger? 

Thx 4 help
1 answer
  1. Jun 29, 2017, 8:03 AM
    Hello Mathias,

    First I hope you are doing this before insert of Event Object.

    To get the id of inserted Visit Report records:

    trigger on event Create visitreport__c (before insert){

    list<visitreport_c> visitreports = new list<visitreport_c>();

    // bulkify business logic start

    ...

    ...

    // bulkify business logic end

    insert visitreports;

    //but you have to handle it bulk update as well

    for(visitreport_c vr:visitreports){

    system.debug('Id:'+vr.id);

    }

    }

    I hope it will help you.
0/9000