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
carramrod81carramrod81 

Cannot deploy trigger to server with Eclipse

Hi,
I've created a trigger, and be it with my dev account or my production account, when i try and deploy with Eclipse, i get "Cannot deploy to project's organization" on the first page of the deploy wizard. I know my trigger works, as i've uploaded it and made it active on my development account, but obviously that isn't possible on production. This was modified from one of the cookbook examples on lead deduplication.

Please help:

trigger trDuplicatePreviousUserCodeCheck on Previous_User_Code__c (before insert, before update) {
Map<String, Previous_User_Code__c> ucMap = new Map<String, Previous_User_Code__c>();
for(Previous_User_Code__c puc : System.Trigger.new) {
    if((puc.Name != null) && (System.Trigger.isInsert ||
                                (puc.Name != System.Trigger.oldMap.get(puc.ID).Name))) {
                                   
                    if(ucMap.containsKey(puc.Name)){
                        puc.Name.addError('Another Account has this same previous user code');
                    } else {
                        ucMap.put(puc.Name, puc);
                    }
            }
}

for(Previous_User_Code__c puc : [SELECT Name FROM Previous_User_Code__c
                                 WHERE Name IN : ucMap.Keyset()]) {
        Previous_User_Code__c newPuc = ucMap.get(puc.Name);
        newPuc.Name.addError('This user code already exists.');
                                 }
   
}

i did read that i need some sort of test class, so i tried to create one but am still getting the same results. I created the class and did Force.com -> Run Tests and it does it's thing, but when i try and go back to the trigger to deploy, i get nothin. Am i doing all this correctly?

public class DuplicatePreviousUserCodeCheckTests {
  static testMethod void testUserCodeDupePreventer()
  {
      Set<String> testUserCodes = new Set<String>;
      testUserCodes.add('1');
      testUserCodes.add('2');
      testUserCodes.add('3');
      System.assert([SELECT count() FROM Previous_User_Code__c
                      WHERE Name IN: testUserCodes] == 0)
                     
      Previous_User_Code__c code1 = new Previous_User_Code__c(Name='1',Account=0014000000Hb89g,
                                                              Previous_User_Code='1');
      insert Previous_User_Code__c
     
  }
}


Message Edited by carramrod81 on 05-27-2008 09:23 AM
werewolfwerewolf
Does it give you any indication when you try to deploy as to your percentage of test coverage?  It has to be at least 75% in production.
Greg HGreg H
I am receiving this same error.  I think it might have something to do with the upcoming summer release but I am not positive.
-greg
carramrod81carramrod81
i figured mine out, there isn't a lot of information on how to deploy correctly with eclipse.
What you need to do is this:
DO NOT connect an eclipse project with your production account.
I connected my dev account only. After i had all my testMethods covering 75%+ of my code, i then hit "Deploy to server". At this point, enter your credentials for your production account, and go through the deployment plan.

if you have an eclipse project connected with your production environment, i'd delete it. Only create a project with your dev environment.
Greg HGreg H
Oddly, my issue worked itself out too. I did not make any changes to my settings but as of today I am able to deploy my code again. I can't explain it but I'm glad that it's working now.
-greg