+ Start a Discussion

Trigger insert new record in custom object

I've created a simple trigger that will fire whenever a new case is created.  The trigger intent is to send case data to a custom object "Tickets".

I'm receiving an error on 5 - Unexpected Token: 'for'


Any ideas with what I'm doing wrong?





trigger createTicket on Case (after insert) {

    List <Ticket__c> tikToInsert = new List <Ticket__c> 
        for (Case c:Trigger.new) {
			//check if Case that is being inserted meets the criteria
		if (c.Type = "RMA") {  
            Ticket__c t = new Ticket__c (); 
            t.SAP_Return_Order__c = c.SAP_Return_Order__c; // map case fields to new ticket object that is being created with this case
            t.Subject__c = c.Subject; 



forgot semicolon

List <Ticket__c> tikToInsert = new List <Ticket__c> ();

Ugh!!! Thanks for finding that for me!


Now I'm getting an error on line 8, no viable alternative at character "".  I changed it to single quotes but I still have the same problem.  Any ideas?

give ==, as its string comparision

if (c.Type == 'RMA')