+ Start a Discussion
NyssaNyssa 

Save error: Unable to perform save on all files

Hello,

 

I'm trying to create a simple trigger that will add a hyphen to a custom field. I am using the following code for the trigger:

 

trigger MyTrigger on My_Object__c (before insert, before update) {
for (Integer i=0;i<Trigger.new.size();i++) {
String tmp = Trigger.new[i].My_Field__c;
if ((tmp != null) && (tmp.length() == 9)) {
tmp = tmp.substring(0,3)+'-'+tmp.substring(3,5);
Trigger.new[i].My_Field__c = tmp;
}
}
}

 

And I have the following test case, which runs fine with 0 lines not tested, 100% covered:

 

public with sharing class TestCase {
public static testMethod void testMyTrigger() {
My_Object__c someObject = new My_Object__c();
someObject.Name = 'testing';
insert someObject;
someObject.My_Field__c = '12345';
update someObject;

My_Object__c out = [select My_Field__c from My_Object__c where Id = :someObject.Id];
System.assertEquals('123-45', out.My_Field__c);
}
}

 

And when I try to save in Eclipse 3.4.2 with Salesforce plugin version 16.0.0.200906151227 I get the "Unable to perform save on all files" error. If I comment out the line in the trigger with the substring(), it saves fine. If I uncomment it, I get the error again. What is going on?

Message Edited by Nyssa on 03-09-2010 10:45 PM
S_LieS_Lie
Hmm its weird , it should works. what is the data type of My_Type__c ?
AlexPHPAlexPHP

Are you saving this to a Production instance or are you on a Sandbox?  (sounds like Production instance) 

NyssaNyssa
Thanks for the response. The data type of My_Field__c is Text(80). This is on a Production instance.
AlexPHPAlexPHP

When deploying code to a Production instance and I get that error, it usually means there is some issue with the deployment.

 

Because the Force.com IDE often doesn't give much information, I use the Force.com Migration Tool to deploy complex code (triggers/classes).

 

Using the Migration tool will give you the system log, allowing you to see what the exact error message is, which file it occurred on, and which line number it was initiated by.

 

Debugging without knowing that information is really tough and stressful!

 

So please have a look at the Force.com Migration Tool, there's some setup involved, but overall, it will save you some headaches in the future.

http://www.salesforce.com/us/developer/docs/daas/salesforce_migration_guide.pdf