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
forawormforaworm 

Deploy a trigger from Eclipse Force.com IDE to production environment

Hi all,


I am trying to deploy a trigger to a production environment.

The trigger was created directly within Salesforce (Setup|Crate|Object|Trigger|Button New).
After a long search I decided to install eclipse with Fore.com IDE plugin.

After check in the sandbox version I did some changes on the trigger and save it back to sandbox. It works fine.

Using the deploy wizard within the IDE (Force.com|Deploy to Server ...) does not work.

I guess I need a testclass but I have no idea how to do this and where I have to save this testclass.
Is there a simple step-by-step instuction.

Another problem is that field names and object names between sandbox and production environment differ.
So I have to change some field and object names before deploy the trigger to production environment.
I do not know I that causes any problem.

The trigger:

 

Trigger checkTrialProductAvailable on Trial_Connect_del__c (before insert,before update) { List<ID> TrialProductIDs = new List<ID>{}; List<ID> TrialIDs = new List<ID>{}; for(Trial_Connect_del__c objTrial_Connect : Trigger.new){ if(objTrial_Connect.Trial_Product_RoW__c != null){ TrialProductIDs.add(objTrial_Connect.Trial_Product_RoW__c); TrialIDs.add(objTrial_Connect.Trial_ROW__c); } } if(TrialProductIDs.size() > 0){ if(TrialProductIDs.size() == 1){ ID myCurrentT_Id = TrialIDs.get(0); Trial_ROW__c myCurrentTrialObj = [SELECT Trial_Actual_Ship_Date__c, Verf_gbar_ab__c FROM Trial_ROW__c T WHERE T.ID = : myCurrentT_Id]; Date myCurrentTrial_Actual_Ship_Date = myCurrentTrialObj.Trial_Actual_Ship_Date__c; Date myCurrentTrial_Verf_gbar_ab_Date = myCurrentTrialObj.Verf_gbar_ab__c; Map<ID,Trial_Connect_del__c> mapTrial_ConnectFields = new Map<ID,Trial_Connect_del__c>([ Select Id, Trial_ROW__c, Trial_Product_RoW__c From Trial_Connect_del__c Where Trial_Product_RoW__c in :TrialProductIDs]); List<ID> myList = new List<ID>(mapTrial_ConnectFields.keySet()); Trial_Connect_del__c myTC; Trial_ROW__c myT; ID myIdT; List<ID> listTrialID = new List<ID>(); for(ID myID : myList){ myTC = mapTrial_ConnectFields.get(myID); myIdT = myTC.Trial_ROW__c; if(myIdT != null){ listTrialID.add(myIdT); } } List<Trial_ROW__c> objListTrial = new List<Trial_ROW__c>(); objListTrial = [SELECT T.Name FROM Trial_ROW__c T WHERE (T.ID IN :listTrialID) AND ((T.Verf_gbar_ab__c > :myCurrentTrial_Actual_Ship_Date) AND (T.Trial_Actual_Ship_Date__c < :myCurrentTrial_Verf_gbar_ab_Date)) ]; List<String> listStrTrialName = new List<String>(); for(Trial_ROW__c objTrialName : objListTrial){ listStrTrialName.add(objTrialName.Name); } if(listStrTrialName.isEmpty() == false){ Trial_Connect_del__c objTrial_Connect2 = trigger.new[0]; objTrial_Connect2.addError('Trial Product is occupied by other Trial(s) ' + listStrTrialName); } } else{ Trial_Connect_del__c objTrial_Connect3 = trigger.new[0]; objTrial_Connect3.addError('Unexpected count of Trial Products!'); } } }

 

Summary Log:

 

*** Deployment Log *** Result: FAILED Date: 30. Oktober 2009 12:22:44 MEZ # Deployed From: Project name: BerchtoldSandbox Username: salesforce@hwi.info Endpoint: test.salesforce.com # Deployed To: Username: salesforce@hwi.info Endpoint: www.salesforce.com # Deploy Results: File Name: package.xml Full Name: package.xml Action: UPDATED Result: SUCCESS Problem: n/a File Name: triggers/checkTrialProductAvailable.trigger Full Name: checkTrialProductAvailable Action: UPDATED Result: SUCCESS Problem: n/a # Test Results: checkTrialProductAvailable Testabdeckung für ausgewählte Apex Trigger beträgt0 %; mindestens 1 % Testabdeckung erforderlich Die durchschnittliche Testabdeckung für alle Apex-Klassen und -Auslöser beträgt 37 %; mindestens 75 % Testabdeckung ist erforderlich

 

Debug Log:

 

*** Beginning Test 1: unsubscribe.static testMethod void testUnsubscribe2() 20091030131033.922:Class.unsubscribe.testUnsubscribe2: line 134, column 4: Insert: SOBJECT:Lead 20091030131033.922:Class.unsubscribe.testUnsubscribe2: line 134, column 4: DML Operation executed in 123 ms 20091030131033.922:Class.unsubscribe.testUnsubscribe2: line 141, column 4: Insert: SOBJECT:Contact 20091030131033.922:Class.unsubscribe.testUnsubscribe2: line 141, column 4: DML Operation executed in 44 ms 20091030131033.922:Class.unsubscribe.handleInboundEmail: line 76, column 3: No Unsuscribe word found in the subject line. 20091030131033.922:Class.unsubscribe.testUnsubscribe2: line 149, column 4: returning Messaging.InboundEmailResult from method global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail, Messaging.InboundEnvelope) in 2 ms 20091030131033.922:External entry point: returning from end of method static testMethod void testUnsubscribe2() in 214 ms Cumulative resource usage: Resource usage for namespace: (default) Number of SOQL queries: 0 out of 100 Number of query rows: 0 out of 500 Number of SOSL queries: 0 out of 20 Number of DML statements: 2 out of 100 Number of DML rows: 2 out of 500 Number of script statements: 38 out of 200000 Maximum heap size: 0 out of 1000000 Number of callouts: 0 out of 10 Number of Email Invocations: 0 out of 10 Number of fields describes: 0 out of 10 Number of record type describes: 0 out of 10 Number of child relationships describes: 0 out of 10 Number of picklist describes: 0 out of 10 Number of future calls: 0 out of 10 Number of find similar calls: 0 out of 10 Number of System.runAs() invocations: 0 out of 20 Total email recipients queued to be sent : 0 Stack frame variables and sizes: Frame0 *** Ending Test unsubscribe.static testMethod void testUnsubscribe2() *** Beginning Test 2: unsubscribe.static testMethod void testUnsubscribe() 20091030131034.141:Class.unsubscribe.testUnsubscribe: line 103, column 4: Insert: SOBJECT:Lead 20091030131034.141:Class.unsubscribe.testUnsubscribe: line 103, column 4: DML Operation executed in 42 ms 20091030131034.141:Class.unsubscribe.testUnsubscribe: line 110, column 4: Insert: SOBJECT:Contact 20091030131034.141:Class.unsubscribe.testUnsubscribe: line 110, column 4: DML Operation executed in 21 ms 20091030131034.141:Class.unsubscribe.handleInboundEmail: line 33, column 3: SelectLoop:LIST:SOBJECT:Contact 20091030131034.141:Class.unsubscribe.handleInboundEmail: line 33, column 20: SOQL query with 1 row finished in 69 ms 20091030131034.141:Class.unsubscribe.handleInboundEmail: line 33, column 3: Number of iterations: 1 20091030131034.141:Class.unsubscribe.handleInboundEmail: line 45, column 5: Update: LIST:SOBJECT:Contact 20091030131034.141:Class.unsubscribe.handleInboundEmail: line 45, column 5: DML Operation executed in 102 ms 20091030131034.141:Class.unsubscribe.handleInboundEmail: line 53, column 3: SelectLoop:LIST:SOBJECT:Lead 20091030131034.141:Class.unsubscribe.handleInboundEmail: line 53, column 17: SOQL query with 1 row finished in 8 ms 20091030131034.141:Class.unsubscribe.handleInboundEmail: line 63, column 12: Lead Object: Lead:{Name=Rasmus Mencke, Email=rmencke@salesforce.com, HasOptedOutOfEmail=true, Id=00Q2000000DoRoHEAV} 20091030131034.141:Class.unsubscribe.handleInboundEmail: line 53, column 3: Number of iterations: 1 20091030131034.141:Class.unsubscribe.handleInboundEmail: line 66, column 3: Update: LIST:SOBJECT:Lead 20091030131034.141:Class.unsubscribe.handleInboundEmail: line 66, column 3: DML Operation executed in 24 ms 20091030131034.141:Class.unsubscribe.handleInboundEmail: line 73, column 2: Found the unsubscribe word in the subject line. 20091030131034.141:Class.unsubscribe.testUnsubscribe: line 118, column 4: returning Messaging.InboundEmailResult from method global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail, Messaging.InboundEnvelope) in 212 ms 20091030131034.141:External entry point: returning from end of method static testMethod void testUnsubscribe() in 281 ms Cumulative resource usage: Resource usage for namespace: (default) Number of SOQL queries: 2 out of 100 Number of query rows: 2 out of 500 Number of SOSL queries: 0 out of 20 Number of DML statements: 4 out of 100 Number of DML rows: 4 out of 500 Number of script statements: 45 out of 200000 Maximum heap size: 0 out of 1000000 Number of callouts: 0 out of 10 Number of Email Invocations: 0 out of 10 Number of fields describes: 0 out of 10 Number of record type describes: 0 out of 10 Number of child relationships describes: 0 out of 10 Number of picklist describes: 0 out of 10 Number of future calls: 0 out of 10 Number of find similar calls: 0 out of 10 Number of System.runAs() invocations: 0 out of 20 Total email recipients queued to be sent : 0 Stack frame variables and sizes: Frame0 *** Ending Test unsubscribe.static testMethod void testUnsubscribe() Cumulative profiling information: No profiling information for SOQL operations. No profiling information for SOSL operations. No profiling information for DML operations. No profiling information for method invocations.

 

 

 

Hope someone can help.

 

Thanks! 

 

 

VarunCVarunC

Yes to deploy in Production you need a TestClass for sure. And that test calls MUST cover atleast 75% of the code.

 

Code Coverage means in your Test Class you Practically Create/Update/Delete records or Read them In such a way they Directly execute Line by Line of the Trigger in concern. So More the Lines of trigger are covered the higher will be your code coverage percntage.

 

One thing Must be taken into care is that In your Test Class you try to prodcue each and every case of operation, the trigger tested with Bulk updations also a very good idea.

 

There are a lot of Blog posts an wiki articales regarding Test methods.

http://wiki.developerforce.com/index.php/An_Introduction_to_Apex_Code_Test_Methods