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
unikevinunikevin 

"Unable to perform save on all files..." always shows up

Hi,
 
I wrote some apex codes . It runs well in the developer environment,but when I deploy it into the production environment , the error message "Unable to perform save on all files: NumberFormatException: For input string" always shows up.
I write the codes with Force.com IDE.
 
Here is a sample:
 
Code:
public class CreateAccount {
 public static void verifyDealer(Account a){
  //if(UserInfo.getProfileId()=='00e20000000lJU1AAM') {
   a.addError('access denied');
  //}
 }
 
 static testMethod void test_verifyDealer(){
  Account a = new Account(Name='test');
  CreateAccount.verifyDealer(a);
 }
} 

 
Any help would be appreciated!
 
Thanks & Regards,
 
Kevin
unikevinunikevin
I find the codes have been deployed into the production environment and can be runtest with 100% coverage. So I think there are some bugs in the Eclipse IDE,it always returns a wrong error message.
 
And another question is : how to active the triggers ?How can I active them manually ?
jpizzalajpizzala
To activate Triggers in production, you will have to put <active>true</active> in the Trigger's meta data then redeploy.

If you have appropriate code coverage and no other errors in the code, it should activate. Currently, there is no way to activate production Triggers through the Salesforce interface like you can in a development org.


Message Edited by jpizzala on 04-11-2008 05:39 PM
unikevinunikevin
Hi jpizzala,
 
Thanks for your help !
 
I tried to set <active>true</active> in meta data,but the trigger is still inactive.The Eclipse says "file only saved locally, not to server". I think the trigger depends on the Class and the Class's coverage is less than 75% in Eclipse,but the class is exactly saved into SFDC and test coverage is 100%. I don't know how to fix it...

here is a sample:

Code:
public class DealderCreateAccount {
 public static void verifyDealer(Account[] accs){
  for (Account a:accs){
   
   
   if(UserInfo.getProfileId()=='00e20000000lJU1AAM') {
    a.addError('access denied');
   }
   
  }
 }
 
 static testMethod void test_verifyDealer(){
  Account acc = new Account(Name='a',Area__c='SH'); 
  DealderCreateAccount.verifyDealer(new Account[]{acc});
 }
}

The codes' test coverage in Eclipse is 66% And in the active org is 75% .. why?


Regards,
 
Kevin


Message Edited by unikevin on 04-13-2008 08:31 PM
jpizzalajpizzala
My guess would be the following chunk:

Code:
if(UserInfo.getProfileId()=='00e20000000lJU1AAM') {
  a.addError('access denied');
}

The record 00e20000000lJU1AAM exists only in your dev or production org, but it is highly unlikely that it is in both. Since you have 75% coverage in production and less in development, I would assume that the dev org does not have this record. Thus the IF statement will always be false in dev, reducing the coverage percentage.

Obviously this takes some working around when you are ready to deploy to production - you will have to change the SFID to reflect an existing record in the org you are trying to deploying to.

This probably won't solve your production trigger activation issue, but it may allow an underlying error to shine through.

It sounds like the code you posted is exactly as it is in your production org. Have you performed Run All Tests? This will give you an idea as to what is truly being covered by your Apex Classes and what is not. Since your trouble trigger is not activated, it won't show up on the Run All Tests report, but it may provide the coverage necessary for you to activate the trigger.

If this doesn't help, have you tried deploying with the Ant build tool? Sometimes Ant will provide you with errors that the IDE does not.

jeremyfrey1jeremyfrey1

When you run the test in your sandbox, what lines show up as not being tested?

My guess is that your coverage doesn't include the addError line.  The best way I've found to test error messages is to use try/catches in unit tests:

 

Psuedocode:
 
Account successAcc = new Account(Name='a', CreatedById=NormalUser.Id);
Insert(successAcc);
Test.assertNotEquals(successAcc.Id,null);
try
{
  Account failAcc = new Account(Name='b',CreatedById=DealerUser.Id);
  Insert(failAcc);
  Test.assertEquals(true,false); // should never get here

}
catch (Exception ex)
{
  Test.assertEquals(true,true); // should always exception here
}


 There might be a better way, but I haven't figured it out yet.  addError always seems to cause a DmlException when Inserting/Updating from code.