Skip to main content
I have a custom object Strategy__c.

 

I would like to create a record for another custom object (EMC_Task__c), upon creation of a Strategy record (noted above).

 

I have been trying to manipulate existing code, but I am getting a lot of Syntax errors.

 

Any help would be appreciated.

 

Thank you!
4 件の回答
  1. 2013年4月24日 21:10
    Goto the Object --> on Trigger Section of the object detail --> click new

     

    might look like this

     

    difference between before and after trigger

     

    http://hisrinu.wordpress.com/2011/05/17/difference-between-before-trigger-and-after-trigger/

     

    Trigger MyCustomTriggerName on Strategy__c (after insert)

     

    {

     

      // You need to bulkify the code : expect more than one record coming into the trigger at one point of time

     

      List<EMC_Task__c> ts = new List<EMC_Task__c>();

     

    for(Strategy__c s:Trigger.new)

     

    {

     

       EMC_Task__c t = new EMC_Task__c ();

     

       t.yourField__c = 'Some values';

     

      ts.add(t);

     

    }

     

      // inserts all the EMC Tasks in the collection

     

     insert ts;

     

    }

     

    If this answers your question, please mark it as solved so that it may help others who're looking for the solution