• jason_best
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

I am very new to SF, but I'm building out a Student Recruiting App for 
my org.  I would love some feedback on the design of this trigger I 
just created.  I'm not sure how much background you need on the data 
structure of the app to provide feedback, but I will give you a basic 
overview. 

 

  • Education Object is detail to to Contact - used to show all schools a 
    prospect has attended.
  • Education has Account Lookup field for link back to School(Account 
    Record) 
  •  Enrollment is Child to Contact - used to Inquiry through graduation 
    for students 
  •  Application is Child to Enrollment 
  •  Document is Child to Application 

I hope that's enough to make sense of it all.  Here is the trigger.  It works just fine, but I 
would love to hear from the experts if this looks like it will scale 
well and any other feedback you are willing to offer. 

 

trigger CreateDocuments on Application__c (after insert) { 

List<Document__c> createdocument = new List <Document__c> {}; 
	for (Application__c app : trigger.new) { 
		List<Contact> c=[SELECT Id,Name FROM Contact WHERE 
		Id=:app.Contact__c]; 
		List<Education__c> ed = [SELECT School__c FROM Education__c WHERE 
		Student__c=:c]; 
		if(app.Recieved_Method__c <> 'Online'){ 
			for(Education__c e : ed){ 
			createdocument.add(new Document__c ( Name = 'Transcript', 
			Application__c =app.id,School__c=e.School__c,Contact__c=app.Contact__c)); 
			} 
		createdocument.add(new Document__c ( Name = 'Recommendation 1', 
		Application__c = app.id,Contact__c=app.Contact__c)); 
		createdocument.add(new Document__c ( Name = 'Recommendation 2', 
		Application__c = app.id,Contact__c=app.Contact__c)); 
		} 
	} 
try { 
	insert createdocument; 
} 
catch (Exception Ex) 
{ 
system.debug(Ex); 
}

 

I am very new to SF, but I'm building out a Student Recruiting App for 
my org.  I would love some feedback on the design of this trigger I 
just created.  I'm not sure how much background you need on the data 
structure of the app to provide feedback, but I will give you a basic 
overview. 

 

  • Education Object is detail to to Contact - used to show all schools a 
    prospect has attended.
  • Education has Account Lookup field for link back to School(Account 
    Record) 
  •  Enrollment is Child to Contact - used to Inquiry through graduation 
    for students 
  •  Application is Child to Enrollment 
  •  Document is Child to Application 

I hope that's enough to make sense of it all.  Here is the trigger.  It works just fine, but I 
would love to hear from the experts if this looks like it will scale 
well and any other feedback you are willing to offer. 

 

trigger CreateDocuments on Application__c (after insert) { 

List<Document__c> createdocument = new List <Document__c> {}; 
	for (Application__c app : trigger.new) { 
		List<Contact> c=[SELECT Id,Name FROM Contact WHERE 
		Id=:app.Contact__c]; 
		List<Education__c> ed = [SELECT School__c FROM Education__c WHERE 
		Student__c=:c]; 
		if(app.Recieved_Method__c <> 'Online'){ 
			for(Education__c e : ed){ 
			createdocument.add(new Document__c ( Name = 'Transcript', 
			Application__c =app.id,School__c=e.School__c,Contact__c=app.Contact__c)); 
			} 
		createdocument.add(new Document__c ( Name = 'Recommendation 1', 
		Application__c = app.id,Contact__c=app.Contact__c)); 
		createdocument.add(new Document__c ( Name = 'Recommendation 2', 
		Application__c = app.id,Contact__c=app.Contact__c)); 
		} 
	} 
try { 
	insert createdocument; 
} 
catch (Exception Ex) 
{ 
system.debug(Ex); 
}