+ Start a Discussion

Unable to save a apex trigger in Force.com IDE



I am using eclipse to write a new apex trigger.




and I am getting the attached error message. Any help would be great.


I am getting error message. An expected error has occurred.

trigger RequestLineItem_AfterInsert on Request_Line_Item__c (after insert) {
	for(Request_Line_Item__c reqli: trigger.new){
		List<Product_Group__c> pg = [Select p.id, p.Technical_Owner__c, p.Business_Owner__c From Product_Group__c p where Product_Group__c =
										:reqli.Product_Group__c LIMIT 1];
		//reqli.Product_Group_Object__c = pg.get(0).id;
		update reqli;




At a quick glance I noticed you are performing DML within a loop, which is a bad thing in a trigger.  See bulkified triggers.


However, I can't help you with receiving "An expected error has occurred" :)  You probably meant unexpected.  Anyway, you also are creating a:




where the return value is always 1 element - "limit 1"


Next, you're making no change to anything since the change that I assume was going to be made is commented out so you are performing an update in a loop on data that hasn't changed:


      update reqli;


But as for the unexpected error when trying to save the trigger??  I'd kill your project in Eclipse and create a new one with your login, password and security token.  Projects occasionally need to be rebuilt.


Hope that helps.





Do you have any error decorators to the right of the scrollbar on the source - i.e. a red square at the top or red bars below?


Also, what org are you trying to save the trigger to - if its a production org it won't allow you to save directly.