function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
neshnesh 

my code sample:How to use trigger below logic:-please help me

How to use Trigger -below logic--: wheneverTraining object survey  flag true i want to insert field into Training survey object..and also insert record type ..please help me..

------------------------------------------------------

List <training__c> t1 = new list <training__c>();
       list <training_survey__c> ts2 = new list<training_survey__c>();
       t1 = [ select day1surveyflag__c, day3surveyflag__c, day5surveyflag__c from training__c where day1surveyflag__c = true or day3surveyflag__c = true or day5surveyflag__c = true ];
       for(training__c tx : t1)
          { 
             training_survey__c ts = new training_survey__c();
             ts.training__C = tx.id;
             if(tx.day1surveyflag__c == true ) 
               {
                 ts.Survey_Type__c = 'Day1';
               }else
             if(tx.day3surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day3';
               }else
             if(tx.day5surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day5';
               }else
               {
                 ts.Survey_Type__c = 'Dropped';
               } 
             RecordType r = [Select id from Recordtype where sobjecttype = 'training_survey__c' and name= :ts.Survey_Type__c];
             ts.RecordTypeid = r.id;
             ts2.add(ts); 
          } 
        if(ts2 != null )
         {
           insert ts2;  
         }     

GlynAGlynA

This is a duplicate of a post in the Apex Development thread:

 

Click here to go to the post in the other thread.